Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3832655ima; Mon, 4 Feb 2019 06:02:01 -0800 (PST) X-Google-Smtp-Source: ALg8bN4gFXowD95UW60NzlEhJu2U96F3c9cx0zgQe7NIWH7n6PVV6N3NRzlXWQ4g8l+hIJcOJHuK X-Received: by 2002:a62:4549:: with SMTP id s70mr50726553pfa.233.1549288921387; Mon, 04 Feb 2019 06:02:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549288921; cv=none; d=google.com; s=arc-20160816; b=px5eUJm5D+CKYJkkqNGZEn2VhB3c7+I0haSgoalQLaYJehG2QZzrAbyS4twdFoxlCU hBvM2p9KAzlr1LpLd9aTEY6gqt1DE2oMa4zwfbsaHij4IW/N3XGWtbyv5LNqEjiYGqVY mm8lqv0xmcAtEx5eEXYucfiTg1g1jTDf4fCpmIMVqW7OJ71Obj1tp+XTEe56TDxwOSHA G19XKnholcSdrYICxccXiIcmMmnhRj052paR6+jR+Tkz0XD2jsRjUy7aU55hzgsfULz5 7DkZuUUw2ZktqKTHgcRdLulk0jiUOmct2FiEcNIOasp3bt/1dR1ksSfyHvGupqqo5fII V/rw== 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=wO6ynLtmevmpRD5fUtnHjwlN+hSKcwlOqadHdNO2Oxw=; b=cAzoXNYq8AByX+xU+f6xQm9DNKDwKfN2IMq0q05kiQ44hMIWpYwWD2p8Ko++L+rqSI NjQz4WCiT4QmMhWwegNwW9NA+VNaIC1IcAk3NdHawYKZTUY6igZoQAUZ7vYnn1nFBfGP OiBiiC3STlAwOy5gQFu6OMk/dHJuK8k+bsHHvSbIvzftkCHr7WX6aDo5O6YukustTCIN L1RaB7wgtNTMuYBMI4eqokN3aHIvdsDihH/Hcjk3KBu8apoD1mGEvKspMkAnVfWVg9V6 DvoJC6iS5W5vGKGrCYCzL4EotQYfP9KbZkfqNhQGOkND+l+xAwtLMY4klnkrEPgoF2Dk WDug== 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 c4si125055pfi.110.2019.02.04.06.01.44; Mon, 04 Feb 2019 06:02:01 -0800 (PST) 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 S1728799AbfBDLki (ORCPT + 99 others); Mon, 4 Feb 2019 06:40:38 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:38999 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726603AbfBDLkh (ORCPT ); Mon, 4 Feb 2019 06:40:37 -0500 Received: by mail-ot1-f68.google.com with SMTP id n8so12391306otl.6; Mon, 04 Feb 2019 03:40:37 -0800 (PST) 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=wO6ynLtmevmpRD5fUtnHjwlN+hSKcwlOqadHdNO2Oxw=; b=odFibkwkQ0H53lZDZ6iAd/nbYuRuxfHi/U+KlVKR2FjoDFm2aybHwsCkVzMeZCWmKI YLlGCLpgTVwyC5uPUtsbpD2d5Rqu6GP8jaDBHEYln81D+K4uuvjkCMfVzPb+NSz9LlZ/ mcavCFdzparIx3g8Y4heF9jmGgEVufm9yJB6yRo7KZl7ofXb61MusF6FTMAD3clWx3nB rKrhq4WhPQM+KktOk4d2TxqHVrxMQu0I1Xahp2P7xDha67MmNzyn9bvH5Z4FbhCV3jli BLaQKfZ7HdR2J7RasOPtxt7UpE9ClSG8G9WPSFek7rA3Qi/G+UERsCTURf01woXyPBUy Y/OQ== X-Gm-Message-State: AHQUAub/ACoNOdvC6qQTKm6qutdkA+ghOjpP+Y4a/jg6cs+M/akmmumi JptqubpG2L6yDnbHwZxy0zqGDDHfwtOIQgZ1f7Q= X-Received: by 2002:aca:c591:: with SMTP id v139mr4725047oif.76.1549280437058; Mon, 04 Feb 2019 03:40:37 -0800 (PST) MIME-Version: 1.0 References: <1952449.TVsm6CJCTy@aspire.rjw.lan> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 4 Feb 2019 12:40:25 +0100 Message-ID: Subject: Re: [PATCH v2 0/9] driver core: Fix some device links issues and add "consumer autoprobe" flag To: Ulf Hansson Cc: "Rafael J. Wysocki" , Greg Kroah-Hartman , LKML , Linux PM , Daniel Vetter , Lukas Wunner , Andrzej Hajda , Russell King - ARM Linux , Lucas Stach , Linus Walleij , Thierry Reding , Laurent Pinchart , Marek Szyprowski , Joerg Roedel 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 Fri, Feb 1, 2019 at 4:18 PM Ulf Hansson wrote: > > On Fri, 1 Feb 2019 at 02:04, Rafael J. Wysocki wrote: > > > > Hi Greg at al, > > > > This is a combination of the two device links series I have posted > > recently (https://lore.kernel.org/lkml/2493187.oiOpCWJBV7@aspire.rjw.lan/ > > and https://lore.kernel.org/lkml/2405639.4es7pRLqn0@aspire.rjw.lan/) rebased > > on top of your driver-core-next branch. > > > > Recently I have been looking at the device links code because of the > > recent discussion on possibly using them in the DRM subsystem (see for > > example https://marc.info/?l=linux-pm&m=154832771905309&w=2) and I have > > found a few issues in that code which should be addressed by this patch > > series. Please refer to the patch changelogs for details. > > > > None of the problems addressed here should be manifesting themselves in > > mainline kernel today, but if there are more device links users in the > > future, they most likely will be encountered sooner or later. Also they > > need to be fixed for the DRM use case to be supported IMO. > > > > On top of this the series makes device links support the "composite device" > > use case in the DRM subsystem mentioned above (essentially, the last patch > > in the series is for that purpose). > > > > Rafael, Greg, I have reviewed patch 1 -> 7, they all look good to me. > > If not too late, feel free to add for the first 7 patches: > > Reviewed-by: Ulf Hansson Thanks! > Although, I want to point out one problem that I have found when using > device links. I believe it's already there, even before this series, > but just wanted to described it for your consideration. > > This is what happens: > I have a platform driver is being probed. During ->probe() the driver > adds a device link like this: > > link = device_link_add(consumer-dev, supplier-dev, DL_FLAG_STATELESS | > DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); > > At some point later in ->probe(), the driver realizes that it must > remove the device link, either because it encountered an error or > simply because it doesn't need the device link to be there anymore. > Thus it calls: > > device_link_del(link); > > When probe finished of the driver, the runtime PM usage count for the > supplier-dev remains increased to 1 and thus it never becomes runtime > suspended. OK, so this is a tricky one. With this series applied, if the link actually goes away after the cleanup device_link_del(), device_link_free() should take care of dropping the PM-runtime count of the supplier. If it doesn't do that, there is a mistake in the code that needs to be fixed. However, if the link doesn't go away after the cleanup device_link_del(), the supplier's PM-runtime count will not be dropped, because the core doesn't know whether or not the device_link_del() has been called by the same entity that caused the supplier's PM-runtime count to be incremented. For example, if the consumer device is suspended after the device_link_add() that incremented the supplier's PM-runtime count and then suspended again, the link's rpm_active refcount is one already and so the supplier's PM-runtime count should not be dropped. Arguably, device_link_del() could be made automatically drop the supplier's PM-runtime count by one if the link's rpm_active refcount is not one, but there will be failing scenarios in that case too AFAICS.