Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1494922ybb; Thu, 26 Mar 2020 01:41:37 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsMdOoKFIjqFdQA4ADPIF4Gh6lpi3vKvGt9F7ENUNNhUn7BlkrlV9OMLGNJ41KPKHJiMjSq X-Received: by 2002:aca:6184:: with SMTP id v126mr988432oib.168.1585212097393; Thu, 26 Mar 2020 01:41:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585212097; cv=none; d=google.com; s=arc-20160816; b=IsPVDJO49upHoBu+kZdOoGYD1witHjLn9xgZEca/uZ5cVH6PLg9hNdFE/Umag5hLRk KS+02hch5y632dlCxgCJgy3ANTh6dnFyGqr0iFEspQUQElASKQvCcvAuiLdMe6jTsOO3 m1tEVV/IvqxID+qWL1jKt0orDugEGLAN0ggaxAvb3K0M/E2OWsX8GinaGFgbAIsE1f9M 0OdH4jB3VjjTBwhKcsi8V6TTfmfVNVC9o11Wu3Qzc6imC65oe1im2ZuGDyOEakskFFam RNPHPGhEK3I8JR/owl5qZE+3ukJroE/zNmHGxWEvlDGWo7ei4kuEMODvcDElBAoa2fda W+pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=lRX7PLl1mEjB6H0fmMXyLD2J+FG3OvK9KawnS67f2j8=; b=RdwXc8T+RMg5tim1dgL1n1Lcbp4eHuJsxBR6w08zQUyoveqVuQlVycrMQ8hJmKLobX YzqwoagOZz+GNI5iqyxnYPmPy1rLNKEIHZmGG+Qw6jzb1UnR2BQjh0yjB8OnZlJWlnhD hnBajeLGHA6OA2HQUT0Y3AhsKvfYLmk6ZPXrVc2tW1kTzDWC5c8YNEDJA8F4P8PaP+QS 9SCXePqIEsRf296rPOYFbjolFK0WOHZJKrDhpM26oHqwG65qEcCPbypgKWG2e38UfIQ7 cWyxTDARX6aZRsvzYWYdx6QC0xPqjL0G+OxrElCMNGQgBNnYtOq98fQnqzFEWDCO24ox ZdWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e11si773011oib.152.2020.03.26.01.41.24; Thu, 26 Mar 2020 01:41:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727755AbgCZIjw (ORCPT + 99 others); Thu, 26 Mar 2020 04:39:52 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:34513 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbgCZIjw (ORCPT ); Thu, 26 Mar 2020 04:39:52 -0400 Received: by mail-oi1-f196.google.com with SMTP id d3so215719oic.1; Thu, 26 Mar 2020 01:39:51 -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=lRX7PLl1mEjB6H0fmMXyLD2J+FG3OvK9KawnS67f2j8=; b=N1V1c2BsEqE7WYM3otZ/2it1bHYCJx2zxNtIMek1oeYGeSbL3BXxtPiPMjp2ec3Ya1 bim+QIZn8+JbEAJ+P5duvJEWGsDApXxZkwYdPQuJ9nPL2WPiCfbbD47yBKnz55la9nj6 tuRUdNaIoZ/BM/x20E9NaAE0188Qr/J/esNxAtT4EPc/V/IqIbBfWLq+U6++HD60EPIE 3UyeccSSgHn3FH1eRJIRH+J9cckzXjKrvYWYqWH64BgRhipOco51EyEwKBI9cv9jwGrP b0egJgwiKhcGaPklDn4oYZo9LTEghY55IHTGSIEkEcQYWbCAkLxuHM+TdAh0qTpnw0ap 6u6A== X-Gm-Message-State: ANhLgQ25nwdBWQ8RjzeDgf8nIOeVe7MxOhrnnc2IbyYzdVKu/yZoBg/Y eeuP/b6guGdixCb763ctgl6yF9lCwkM6dXH0VmQ= X-Received: by 2002:aca:5155:: with SMTP id f82mr1082932oib.103.1585211991269; Thu, 26 Mar 2020 01:39:51 -0700 (PDT) MIME-Version: 1.0 References: <20200324175719.62496-1-andriy.shevchenko@linux.intel.com> <20200325032901.29551-1-saravanak@google.com> <20200325125120.GX1922688@smile.fi.intel.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 26 Mar 2020 09:39:40 +0100 Message-ID: Subject: Re: [PATCH v3] driver core: Break infinite loop when deferred probe can't be satisfied To: Saravana Kannan Cc: Andy Shevchenko , Andrzej Hajda , Artem Bityutskiy , Felipe Balbi , Mark Brown , Ferry Toth , grant.likely@arm.com, Greg Kroah-Hartman , LKML , Linux PM , Peter Ujfalusi , "Rafael J. Wysocki" , Android Kernel Team Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 25, 2020 at 11:09 PM Saravana Kannan wrote: > > On Wed, Mar 25, 2020 at 5:51 AM Andy Shevchenko > wrote: > > [cut] > > > > Yes, it's (unlikely) possible (*), but it will give one more iteration per such > > case. It's definitely better than infinite loop. Do you agree? > > Sorry I wasn't being clear (I was in a rush). I'm saying this patch > can reintroduce the bug where the deferred probe isn't triggered when > it should be. > > Let's take a simple execution flow. > > probe_okay is at 10. > > Thread-A > really_probe(Device-A) > local_probe_okay_count = 10 > Device-A probe function is running... > > Thread-B > really_probe(Device-B) > Device-B probes successfully. > probe_okay incremented to 11 > > Thread-C > Device-C (which had bound earlier) is unbound (say module is > unloaded or a million other reasons). > probe_okay is decremented to 10. > > Thread-A continues > Device-A probe function returns -EPROBE_DEFER > driver_deferred_probe_add_trigger() doesn't do anything because > local_probe_okay_count == probe_okay > But Device-A might have deferred probe waiting on Device-B. > Device-A never probes. > > > *) It means during probe you have _intensive_ removing, of course you may keep > > kernel busy with iterations, but it has no practical sense. DoS attacks more > > effective in different ways. > > I wasn't worried about DoS attacks. More of a functional correctness > issue what I explained above. The code is functionally incorrect as is already AFAICS. > Anyway, if your issue and similar issues can be handles in driver core > in a clean way without breaking other cases, I don't have any problem > with that. Just that, I think the current solution breaks other cases. OK, so the situation right now is that commit 58b116bce136 has introduced a regression and so it needs to be fixed or reverted. The cases that were previously broken and were unbroken by that commit don't matter here, so you cannot argue that they would be "broken". It looks to me like the original issue fixed by the commit in question needs to be addressed differently, so I would vote for reverting it and starting over. > As an alternate solution, assuming "linux,extcon-name" is coming > from some firmware, you might want to look into the fw_devlink > feature. That would be a workaround for a driver core issue, though, wouldn't it? > That feature allows driver core to add device links from firmware > information. If you can get that feature to create device links from > your dwc3.0.auto (or its parent pci_dev?) to the extcon supplier > device, all of this can be sidestepped and your dwc3.0.auto's (or the > dwc pci_dev's) probe will be triggered only after extcon is probed. > > I have very little familiarity with PCI/ACPI. I spent about an hour or > two poking at ACPI scan/property code. The relationship between a > pci_dev and an acpi_device is a bit confusing to me because I see: > > static int dwc3_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) > { > struct property_entry *p = (struct property_entry *)id->driver_data; > struct dwc3_pci *dwc; > struct resource res[2]; > int ret; > struct device *dev = &pci->dev; > .... > dwc->dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); > .... > ACPI_COMPANION_SET(&dwc->dwc3->dev, ACPI_COMPANION(dev)); > > And ACPI_COMPANION returns an acpi_device by looking at dev->fwnode. > So how the heck is a pci_device.dev.fwnode pointing to an > acpi_device.fwnode? acpi_device is an of_node counterpart (or it is an fwnode itself if you will). Thanks!