Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5802704pxv; Wed, 7 Jul 2021 12:04:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1hfg+92n8sXIi7wFWvZE+B/9p6JvF5sy66JT+/45xNq8GSslubQWp0MmFMvw1LC5QP6B6 X-Received: by 2002:a6b:e916:: with SMTP id u22mr20932751iof.155.1625684686391; Wed, 07 Jul 2021 12:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625684686; cv=none; d=google.com; s=arc-20160816; b=CIt2JtXd1WI8cxD7bpGUkVDL5ZpnRwWe/UMv1WiW9F6+g64Ibat6c+NFDLMCv+o5Gu JovHnGRxzRxotf5z8n3piLmAEKSxy6rSXJROaNw30vcGian3id/8PGvlKIZzteGnvYaW m755e/hsU4QELh8yptvX0/bsT1PBKM9HOUQdwvafVt7r8jvWvtHajwA1GwuFllq4TiIj wnpD6QdPWflwNNPiNg1vlA5i4oS7zaHDUq2GGlNqk+3IKKlI8lSHjva3V4RdlfdbC+hN T60kKVJEKtqewlBHrG2jc15mnbikazSzZnCEOMhP35wYoK3QAS+AfpKSbgkLZykURX8z c0oA== 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=e8u4xPlHjWE3z1kPd6+no/nJC4zF/v0dweDYhSivEqc=; b=HNRkDKprOV9H+TVWKql4iDkqyiO5AaXn0/5cfPCHz4qBgEUnla4gAJqRoR0+0vmR9n LJfeOIjuH7Zt8nLIEci/ziTeIqfXlghvueF+O7aqjdA4Pen6aekx8t0V8F84r4vrlGWm zFheu3G7fxTK10RRFbbMr6tEYIxr5VV2EDJZB6eDHy8a3OefCk7YRA29ujORJyadPMkB nHPb9+8o/ZkEdtSLNmS7cEW+IgOJykj+795s/C1bzkKu/jE/d5SxZ/e6QilaPc/gcExT nQp/hyPuqt+YmEyecCcb84cnze1rZP/naSLCmMqwkEc/46FxqfONMwH1TWvpRSKWBAoi xRcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TSEoUqXj; 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 v14si904942ilj.0.2021.07.07.12.04.34; Wed, 07 Jul 2021 12:04:46 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=TSEoUqXj; 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 S230396AbhGGRsn (ORCPT + 99 others); Wed, 7 Jul 2021 13:48:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbhGGRsm (ORCPT ); Wed, 7 Jul 2021 13:48:42 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3712C06175F for ; Wed, 7 Jul 2021 10:46:00 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id i4so4467960ybe.2 for ; Wed, 07 Jul 2021 10:46:00 -0700 (PDT) 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=e8u4xPlHjWE3z1kPd6+no/nJC4zF/v0dweDYhSivEqc=; b=TSEoUqXjzQlZ1Tdwv7QhxMkGP9zH5n2C9gszCR0sWSXEiZ7R0Dp8hUweTqFEvZmG3n Ku2Ngd1rEAr27dfYNytr59XXAzhJlCXr1KOC7IdUj0VJgU2u3X5uyjtDFttcaHhQHHVc NmITJl4eQw0Rta8GApIvrL0hWBdKqImiu4b+iVo7OKI//SWMuk+mvwhnpAEZ7S8s5pfF WV7tcJfwxmf5LD6p8+95YJhVAY9fjTWM/ZcsYkmQFQWJBJXy93UKSMofoj5dWEJpE5HX +njNJV0Z97G4Or40cJK/kpAh0c9lFZkGhyX7lUCCGPgxBB8SgXSwZqmuEX1So8Q9kX/6 NZLg== 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=e8u4xPlHjWE3z1kPd6+no/nJC4zF/v0dweDYhSivEqc=; b=MUJyyTGMe+S0OXhlEDl7nQUD9E4FxUn1u92hUV+3DxoZwwS5R8h8rSFlwPHvgE/2l7 EdNey1QI6ZclFDVdHrDelFh+24cMR+iih4+gw0V63y7GrFw34GCNPUtaX/vxBNlPw3Cj z1ltT8Onz/usfo/brVv0URghHN/9UrbIxDpHYK5KWz2adzf61G72csBB93Abp3Pu59MU 3JKO03vXVKx9I73aYO8/tPKsGV/bXHa+WUEkiL323qcz1miL4SaU/N7TF/kjn3pCyjlW KT2phl54xT0fh9WDRVKKAfj5OTErvSsU00AB5HhB8sih+JUpOfuI9h7RVw8Vi3TSTXuk ZlNg== X-Gm-Message-State: AOAM530aUvPDFWt3DCmTdmUtbXsk7/RpUgFlq/TTo57fhowa+RWtnWQW VbE1vFpv6zzCGE0hAWL82j66Q6yn3wFdP/67raBp1A== X-Received: by 2002:a25:b3c8:: with SMTP id x8mr33888178ybf.466.1625679959923; Wed, 07 Jul 2021 10:45:59 -0700 (PDT) MIME-Version: 1.0 References: <20210215111619.2385030-1-geert+renesas@glider.be> In-Reply-To: From: Saravana Kannan Date: Wed, 7 Jul 2021 10:45:24 -0700 Message-ID: Subject: Re: [PATCH] driver core: Fix double failed probing with fw_devlink=on To: Geert Uytterhoeven 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 On Wed, Jul 7, 2021 at 1:43 AM Geert Uytterhoeven wrote: > > 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. > Yay! That was the goal :) I'm assuming it wasn't ever applied. -Saravana