Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8408193ybi; Tue, 23 Jul 2019 08:04:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2tQCUVelktYnewmQ/BrCV/8QK4yIKrMEXPXHwljgK2zKOfsSBSiuYTXCOvdsPZmDtN6pl X-Received: by 2002:a17:902:20e9:: with SMTP id v38mr81957564plg.62.1563894248112; Tue, 23 Jul 2019 08:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563894248; cv=none; d=google.com; s=arc-20160816; b=XuwBxAnJ/9azqPW1VJaD8pVyyJHv+10JKvWCC343HZHC4B3SQ0tADDbAv5jZ3uz6WK KRO2C4lLFI4F/6PZqvBGHTC7FoGJzm1s8hx5A2UZuSjA9iEEa/dWbx9V99q268J/m8+N 9rS5gAKB3vncAcwBTBM5f/9LoY7c6Nbkt9/1x0agBQIzetnTJhlh4qUByhb8UNIv8pY+ pxX4UpeEmgfSsqVcHqAZ5nLtb0wC3GP499PviBfRuEne3solyPoADEeOmUSjsOEmlqif qgTGGb+/znMnm/UlF5ppG+KOUvE4aCfQECxGp4ZyQHmIGH8vi4B5b9a1x+gNE4T0cwiF kKGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tYdueLZBS+A1jVmW46NPiOHSTFkX/JzIDUkp3RuHrxI=; b=DjpqWBXZW2lNJOoqBwEMNdxWKy9q3tjQKNOEHacnS0zoN7r3TVSa0pq3ICXIkn7ql1 YjvirRx7OeWg3uiRT1JhnVbWeSrKMyAZ4ClfWwgkenvsmulnQUr6oKmDX9tYGAEknZRh br9uAQzoZ6YKj6u4vNxYB7YuZ0PyiQ7es/0qKV31/L5mAYaOd8YkAchccjPunl58MhEe fqCJjdaj/wY713ISTnhw6joKp2J3D0knchr9hNQL9AQi3hcxe7FTiqdCxtiOgVIYdVWA yHIm0BbcAFYB0m289aMSOTnKTXtEpeoBi9yyKnwy7ro3auEe/kKLF8+WxykjOMKZGr3j kHAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yyalUf2Y; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si12622986pgj.259.2019.07.23.08.03.43; Tue, 23 Jul 2019 08:04:08 -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; dkim=pass header.i=@kernel.org header.s=default header.b=yyalUf2Y; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388616AbfGWH52 (ORCPT + 99 others); Tue, 23 Jul 2019 03:57:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:35118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388605AbfGWH51 (ORCPT ); Tue, 23 Jul 2019 03:57:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2467A2239E; Tue, 23 Jul 2019 07:57:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563868646; bh=raesEJUrKUUjIY47oo0d7Am8Mms/YmjXGF8ELt5JU0k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=yyalUf2YIUgBilePpnS3sBf6REYxD18aL8zOEZSw0XNEaG7ucE/Q3ipoUm4T3nHA4 h4qLkxVTZEjh8PRY+nO8KIIouncngiAOJ5A+XW0K5GBpzwxwyeRXUdU4yyJMU7wWHU wnTpEzTHqjs6fl/nVs+XxIK4QhpblnNaHCznZ+bY= Date: Tue, 23 Jul 2019 09:57:24 +0200 From: Greg Kroah-Hartman To: "Rafael J. Wysocki" Cc: LKML , Linux PM , Saravana Kannan , Lukas Wunner , Jon Hunter , Ulf Hansson , Marek Szyprowski Subject: Re: [PATCH v2] driver core: Remove device link creation limitation Message-ID: <20190723075724.GB27243@kroah.com> References: <2305283.AStDPdUUnE@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 23, 2019 at 09:34:54AM +0200, Rafael J. Wysocki wrote: > Hi Greg, > > On Tue, Jul 16, 2019 at 5:21 PM Rafael J. Wysocki wrote: > > > > From: Rafael J. Wysocki > > Subject: [PATCH] driver core: Remove device link creation limitation > > > > If device_link_add() is called for a consumer/supplier pair with an > > existing device link between them and the existing link's type is > > not in agreement with the flags passed to that function by its > > caller, NULL will be returned. That is seriously inconvenient, > > because it forces the callers of device_link_add() to worry about > > what others may or may not do even if that is not relevant to them > > for any other reasons. > > > > It turns out, however, that this limitation can be made go away > > relatively easily. > > > > The underlying observation is that if DL_FLAG_STATELESS has been > > passed to device_link_add() in flags for the given consumer/supplier > > pair at least once, calling either device_link_del() or > > device_link_remove() to release the link returned by it should work, > > but there are no other requirements associated with that flag. In > > turn, if at least one of the callers of device_link_add() for the > > given consumer/supplier pair has not passed DL_FLAG_STATELESS to it > > in flags, the driver core should track the status of the link and act > > on it as appropriate (ie. the link should be treated as "managed"). > > This means that DL_FLAG_STATELESS needs to be set for managed device > > links and it should be valid to call device_link_del() or > > device_link_remove() to drop references to them in certain > > sutiations. > > > > To allow that to happen, introduce a new (internal) device link flag > > called DL_FLAG_MANAGED and make device_link_add() set it automatically > > whenever DL_FLAG_STATELESS is not passed to it. Also make it take > > additional references to existing device links that were previously > > stateless (that is, with DL_FLAG_STATELESS set and DL_FLAG_MANAGED > > unset) and will need to be managed going forward and initialize > > their status (which has been DL_STATE_NONE so far). > > > > Accordingly, when a managed device link is dropped automatically > > by the driver core, make it clear DL_FLAG_MANAGED, reset the link's > > status back to DL_STATE_NONE and drop the reference to it associated > > with DL_FLAG_MANAGED instead of just deleting it right away (to > > allow it to stay around in case it still needs to be released > > explicitly by someone). > > > > With that, since setting DL_FLAG_STATELESS doesn't mean that the > > device link in question is not managed any more, replace all of the > > status-tracking checks against DL_FLAG_STATELESS with analogous > > checks against DL_FLAG_MANAGED and update the documentation to > > reflect these changes. > > > > While at it, make device_link_add() reject flags that it does not > > recognize, including DL_FLAG_MANAGED. > > > > Signed-off-by: Rafael J. Wysocki > > Reviewed-by: Saravana Kannan > > Tested-by: Marek Szyprowski > > Do I need to resend this? > > I know that posting new things during a merge window is not most > convenient, sorry about that. No, it's in my queue, give me a few days to dig out from my huge pending patch list, no need to resend it. thanks, greg k-h