Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4748607ima; Tue, 5 Feb 2019 00:17:23 -0800 (PST) X-Google-Smtp-Source: AHgI3IapUOp/Y48wCAx09ZvAG+UqdTc57CADqncQeiMaMwXOMvLJ9W7fmymDqhk3M5Q75X0vlRBu X-Received: by 2002:a63:df50:: with SMTP id h16mr3422995pgj.421.1549354642982; Tue, 05 Feb 2019 00:17:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549354642; cv=none; d=google.com; s=arc-20160816; b=QqfXXRF2hMl+8Cw7Wj527FcgS3YtW6TD4g9dZXeQaDhS9O++0fY6ZVjRhpPNJdCEBd gmPS8+2dMg1Ewimnj4Hn3NY7WFGyNO3Igd5SU34I18VImtv/sn0DaVHC67Yk4HpIqWA8 vbEJieqnmO5dqxk5GTp3d9lmmdnQjV+sBO2igjfhPtJgjwJzVTnyrAa+sqEKQSnpqoYh hUVlWqPMsdj2St/LAuxGlBpQM35C1kX0yeEy6xh1lmI86/gQnZiNomuI5oUKXuttFDbZ ISaU4tMec473ay200YLnM5gVnn0ZHqqJmPL0g5mouElMwgY+tskV6cFtxs1bKZFSW47U 5lYw== 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:dkim-signature; bh=MJRZPHo4UdrivNyUfxxuCBcvinGNtztDTT9MkE5hMQo=; b=Edu3fTwL5U4ldLwpks+sp3N+TJ+nYdS6NPl04Noyn3ouhz9XjTycmnWmLHCjUD00I7 BFJXerHpZ+IxBvyvTS4qreun7LT1F/Py2JAWrb/kxG4+/FN54yMTcK0zUiL0RJfr5+z9 mp9E4RNmI32b9P3e5C9gmmU9iqB6wdavUD2v6Z2aemuU2slIW0VJP11f368rAa39haS7 qmJPIIXdTvL2HnXitFuBVBSwDwHDPzKAcmKS9/vKErYkE/eiGnLYgQQciiaPZWEpbQum tPktRG7TwtUbsbm3ud0h8GlNjLGxN/oqq3rWkJ/IcVbpRX78TN3NAzoVxyCd5O5XtXDO 5HWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ehuZw6Dv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v16si2475154plo.182.2019.02.05.00.17.07; Tue, 05 Feb 2019 00:17:22 -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; dkim=pass header.i=@linaro.org header.s=google header.b=ehuZw6Dv; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727953AbfBEIQ2 (ORCPT + 99 others); Tue, 5 Feb 2019 03:16:28 -0500 Received: from mail-vs1-f68.google.com ([209.85.217.68]:34855 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726780AbfBEIQ1 (ORCPT ); Tue, 5 Feb 2019 03:16:27 -0500 Received: by mail-vs1-f68.google.com with SMTP id e7so1637527vsc.2 for ; Tue, 05 Feb 2019 00:16:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MJRZPHo4UdrivNyUfxxuCBcvinGNtztDTT9MkE5hMQo=; b=ehuZw6DvsokpE/nBdprpY/tgDFN3CKTiqbk2xtyDOv5jRNMSpzcnp8AsSe5isVS64r W4rut2Jw91gg6iSNb6dcNZeAsq3eEESISvwwKL6ImKoVRwBJ0DmW8uC7ES5PwfT+2WrO in+DZUS46XWR816U8M9ERf84hE2Y7VMqM1K0Y= 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=MJRZPHo4UdrivNyUfxxuCBcvinGNtztDTT9MkE5hMQo=; b=SDAeQYqC1PgrpswhGL/+kbdhVGZLy+WdBIwT51CqIv6lIXJBb5rTZE5H7taN37JQMA xeHj4CSUDlwSveVEoe//VrrhO6k8/sbFUIFJZtM5cRX1TYgPcqZXnFMbOSwDKH5l9EbZ Pqxjn8FHfRjKH3m43xFBgIwAXDpMyM0Y+zI8k6KkN3Y/jvoSbXR8pewWnJCr9JHz0gK4 s+8ctETYYitQogzi1QGuYRghT/t4DPlH5e0UN1D3f90YGn0p/7yez42ivicnFoKYWO9b bnT1DNggXqxRYIsKZaIyjrlq+K2n/H6u7k+Vq09QjVugX2WZoFXtv6MpNSsWf3rGV/B9 pi6w== X-Gm-Message-State: AHQUAuZuCcNGPuh5SMt+knW1Ur3bkfQhyIW0qsgi+EGffnvDkuEPK/RY 5yqKTFfdQeQuMsClWJ0QM7ZQS8IjgDfkCE6zpKGO1Q== X-Received: by 2002:a67:1a84:: with SMTP id a126mr1516022vsa.165.1549354586410; Tue, 05 Feb 2019 00:16:26 -0800 (PST) MIME-Version: 1.0 References: <1952449.TVsm6CJCTy@aspire.rjw.lan> In-Reply-To: From: Ulf Hansson Date: Tue, 5 Feb 2019 09:15:49 +0100 Message-ID: Subject: Re: [PATCH v2 0/9] driver core: Fix some device links issues and add "consumer autoprobe" flag To: "Rafael J. Wysocki" 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, 4 Feb 2019 at 12:45, Rafael J. Wysocki wrote: > > 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. Unless this is a of your "distracted part", then I think this is what happening and thus is a problem. > > > > 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. I see what your are saying and I must admit, by looking at the code, that it has turned into being rather complicated. Assuming of good reasons, of course. Anyway, I will play a little bit more with my tests to see what I can find out. > > > 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. Let's see. Kind regards Uffe