From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADBD7C4332B for ; Fri, 5 Feb 2021 09:11:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F62C64F38 for ; Fri, 5 Feb 2021 09:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbhBEJLZ (ORCPT ); Fri, 5 Feb 2021 04:11:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:60348 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbhBEJJl (ORCPT ); Fri, 5 Feb 2021 04:09:41 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 98A5264FC5; Fri, 5 Feb 2021 09:08:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612516139; bh=RS2Nxh+BIHk70SPCLHvH3UHMEVYoRMyAH5V4+gpwaFo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wi3JO5qF/iD6hWWPJclYRvpw0zeikX7qaL+FUPqwt1VQQ6Lj9Mxos9UHNh5zF7W9y NFJQIQiUWNYSz+rP0zrQRhYKvw9bn6EjXfN1CkfHL5ssfnTDhaYgLf3Rm9eYs3rLBm kK6xd5KKpKTEK+mafWe35arr3qi6e8L3GlS3F0sY= Date: Fri, 5 Feb 2021 10:08:51 +0100 From: Greg Kroah-Hartman To: "Rafael J. Wysocki" Cc: Heikki Krogerus , Andy Shevchenko , Felipe Balbi , Mathias Nyman , Linux Kernel Mailing List , "open list:ULTRA-WIDEBAND (UWB) SUBSYSTEM:" Subject: Re: [PATCH v2 1/6] software node: Provide replacement for device_add_properties() Message-ID: References: <20210204141711.53775-1-heikki.krogerus@linux.intel.com> <20210204141711.53775-2-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Thu, Feb 04, 2021 at 05:13:04PM +0100, Greg Kroah-Hartman wrote: > On Thu, Feb 04, 2021 at 05:06:53PM +0100, Rafael J. Wysocki wrote: > > On Thu, Feb 4, 2021 at 3:17 PM Heikki Krogerus > > wrote: > > > > > > At the moment the function device_del() is calling > > > device_remove_properties() unconditionally. That will result into the > > > reference count of the software node attached to the device being > > > decremented, and in most cases it will hit 0 at that point. So in > > > practice device_del() will unregister the software node attached to > > > the device, even if that was not the intention of the caller. Right > > > now software nodes can not be reused or shared because of that. > > > > > > So device_del() can not unregister the software nodes unconditionally > > > like that. Unfortunately some of the users of device_add_properties() > > > are now relying on this behaviour. Because of that, and also in > > > general, we do need a function that can offer similar behaviour where > > > the lifetime of the software node is bound to the lifetime of the > > > device. But it just has to be a separate function so the behaviour is > > > optional. We can not remove the device_remove_properties() call from > > > device_del() before we have that new function, and before we have > > > replaced device_add_properties() calls with it in all the places that > > > require that behaviour. > > > > > > This adds function device_create_managed_software_node() that can be > > > used for exactly that purpose. Software nodes created with it are > > > declared "managed", and separate handling for those nodes is added to > > > the software node code. The reference count of the "managed" nodes is > > > decremented when the device they are attached to is removed. This will > > > not affect the other nodes that are not declared "managed". > > > > > > The function device_create_managed_software_node() has also one > > > additional feature that device_add_properties() does not have. It > > > allows the software nodes created with it to be part of a node > > > hierarchy by taking also an optional parent node as parameter. > > > > > > Signed-off-by: Heikki Krogerus > > > > The rationale is clear now, so > > > > Reviewed-by: Rafael J. Wysocki > > > > and I'm assuming that this will be routed via the USB tree. > > Yes, I will do so, thanks. Now queued up, thanks! greg k-h