Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp3841530ima; Mon, 4 Feb 2019 06:09:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN72vNPrEt65qm8MIie2DopwycvyOJNfVq1lRvjTFj0GKHYhLxQ38zYlnTiLjND/ObFoPKyr X-Received: by 2002:a17:902:bd0b:: with SMTP id p11mr52286906pls.259.1549289355732; Mon, 04 Feb 2019 06:09:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549289355; cv=none; d=google.com; s=arc-20160816; b=wtKhPt8BG70dcLos/YpDltNjaf6jjveZ2kXtB9ZNQLo2Ot/S1eCO2mdjcbe9LbgOTC zqeDJVbgtEbv9cZTwA+5zHG+6TaqwHmobLpfk7YsDO7790PUxrY8w6QMguWTgyqyjyJq VKYFqHjKIYGO3BCdONaQdx5qNCUK9WGNkW7IUdqBNaQcAaoofYa3iPj3BwbVSFlVNj6D ogZcZeGyxm4+fxY7OhGGuGx58e7skmPjovC0yzqNYPw8cWqa3X7iqZGdABcwQxn0Tbth TIUq+xhLaw/TjH0zbIyoL7MFuyTmFgSE78GcZ5YL46N4Ydmtc5q5xy7VsQLkStJDTXod juvA== 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=oDMd1/KseNxwLMzd7R64vjGBztcsoAp+VNDiIkuuGQ0=; b=x317FVVCj289wwbMGd8R/Tctprvr4hCw8KZAk9fXMC6j3W2uWlCHFwi7Cr1XDASMeP xLHru4iHVDsnKRP1GVwySD1PFBlEpbmYwZt4bh/JqcwFYlLCaH6/pdMnCjDwFoH/3KEF ZoCXoEnXFckK5/n3kDvJt4bAlwPjEBHp3hnxEP0jicp5b+nBB1Y9AilosHHsEVp+HtuY F6oitCxj/VIbnsCKfU2+isiumvsVUsbKx87M7heRUZDDtUv8fAM9w4btwfMzuddzcCYn u1yicipSjEDg2gE3C5RNkt/VaoZRxb3FRyOXcJecD+j+D+H8dWGtmKyWyWPuryM3koiT KuPg== 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 p126si94683pgp.529.2019.02.04.06.08.58; Mon, 04 Feb 2019 06:09:15 -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 S1729399AbfBDLpf (ORCPT + 99 others); Mon, 4 Feb 2019 06:45:35 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:37978 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726603AbfBDLpd (ORCPT ); Mon, 4 Feb 2019 06:45:33 -0500 Received: by mail-ot1-f65.google.com with SMTP id e12so12414994otl.5; Mon, 04 Feb 2019 03:45:32 -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=oDMd1/KseNxwLMzd7R64vjGBztcsoAp+VNDiIkuuGQ0=; b=JTu2nNFlh/mXvawnLG3p//sRajPQP01xJjyKkUU7IbR4hemFsdY7rLwJKhgd9qPQ/B eDcKIL3eXFHNlE5EF23eGey9LSrlz7JQ6NByy9XIfAqLb7txrFNm581sDtIWE7DC0819 SPzoSAQCXnifLbFfxN1ESTotp8/F5VbfPxPXk+4le5VQkgTWsWOfnjwvq4pyA+q6L4QN ijSKAtSJunenL3QGNqMBPG2plks3OSitzGukP8a81Eb2eQhkHIQIyvzjbe/0SxjOrZTi Tky9sPiAKbVegg0djOFoCSW5l33VoybnFseBNuRn1StX6VNK7rJGx5CCW2AdskVrFrfW FHBQ== X-Gm-Message-State: AJcUukcCk+pz4kqUhpF+rLW/9d8pGirgR1TM9E02ed8Dqb+4flbvySe2 0Kr6HO3s02iZb0Jep/EAiNwUsDcXtMZlqC0Aklo= X-Received: by 2002:a9d:4c84:: with SMTP id m4mr34014524otf.124.1549280732116; Mon, 04 Feb 2019 03:45:32 -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:45:20 +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 Mon, Feb 4, 2019 at 12:40 PM Rafael J. Wysocki wrote: > > 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, I was distracted while writing this, sorry for the confusion. So let me rephrase: For example, if the consumer device is suspended after the device_link_add() that incremented the supplier's PM-runtime count and then resumed again, the rpm_active refcount will be greater than one because of the last resume and not because of the initial link creation. In that case, dropping the supplier's PM-runtime count on link deletion may not work as expected. > 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.