Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92767C05027 for ; Fri, 17 Feb 2023 07:37:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229507AbjBQHhT (ORCPT ); Fri, 17 Feb 2023 02:37:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbjBQHhP (ORCPT ); Fri, 17 Feb 2023 02:37:15 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 023B34FCBD; Thu, 16 Feb 2023 23:37:14 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8BC62615C9; Fri, 17 Feb 2023 07:37:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 577F0C433D2; Fri, 17 Feb 2023 07:37:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1676619433; bh=rF2nhK+06ELdbRmCQi57VJGIdRujdnHAVF4wTr7HW1Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vkin1QZwm35J/E67DcAxhmZfKhkXlh5yXtFx4tp2JtU+bWbgKo4o/iGPSN8KtfVxi n/Oj06uwpF57s0G6xj4AVm2xs+MZeCvJCoRDl8WiwKd710KREskPk//EPUnnYC9ehJ 9sG2NedTQxSTBq+wzhJ5XpZyze6KQcJaeHt/mVIU= Date: Fri, 17 Feb 2023 08:37:10 +0100 From: Greg Kroah-Hartman To: Elliot Berman Cc: Alex Elder , Srinivas Kandagatla , Prakruthi Deepak Heragu , Murali Nalajala , Trilok Soni , Srivatsa Vaddagiri , Carl van Schaik , Dmitry Baryshkov , Bjorn Andersson , Konrad Dybcio , Arnd Bergmann , Rob Herring , Krzysztof Kozlowski , Jonathan Corbet , Bagas Sanjaya , Catalin Marinas , Jassi Brar , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v10 08/26] gunyah: rsc_mgr: Add resource manager RPC core Message-ID: References: <20230214211229.3239350-1-quic_eberman@quicinc.com> <20230214212327.3310128-1-quic_eberman@quicinc.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-kernel@vger.kernel.org On Thu, Feb 16, 2023 at 09:40:52AM -0800, Elliot Berman wrote: > > > On 2/15/2023 10:43 PM, Greg Kroah-Hartman wrote: > > On Tue, Feb 14, 2023 at 01:23:25PM -0800, Elliot Berman wrote: > > > +struct gh_rm { > > > + struct device *dev; > > > > What device does this point to? > > > > The platform device. What platform device? And why a platform device? > > > + struct gunyah_resource tx_ghrsc, rx_ghrsc; > > > + struct gh_msgq msgq; > > > + struct mbox_client msgq_client; > > > + struct gh_rm_connection *active_rx_connection; > > > + int last_tx_ret; > > > + > > > + struct idr call_idr; > > > + struct mutex call_idr_lock; > > > + > > > + struct kmem_cache *cache; > > > + struct mutex send_lock; > > > + struct blocking_notifier_head nh; > > > +}; > > > > This obviously is the "device" that your system works on, so what are > > the lifetime rules of it? Why isn't is just a real 'struct device' in > > the system instead of a random memory blob with a pointer to a device? > > > > What controls the lifetime of this structure and where is the reference > > counting logic for it? > > > > The lifetime of the structure is bound by the platform device that above > struct device *dev points to. get_gh_rm and put_gh_rm increments the device > ref counter and ensures lifetime of the struct is also extended. But this really is "your" device, not the platform device. So make it a real one please as that is how the kernel's driver model works. Don't hang "magic structures" off of a random struct device and have them control the lifetime rules of the parent without actually being a device themself. This should make things simpler overall, not more complex, and allow you to expose things to userspace properly (right now your data is totally hidden.) thanks, greg k-h