From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933722AbdKAXIO (ORCPT ); Wed, 1 Nov 2017 19:08:14 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:51884 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752260AbdKAXIM (ORCPT ); Wed, 1 Nov 2017 19:08:12 -0400 X-Google-Smtp-Source: ABhQp+TD1ofJAxb305nMj8fsY6XfBxm3PEovjuNdqWT8P+mQ7yWEz5wD7gNeNqNIhBbP9BmfvFg7NA== Date: Wed, 1 Nov 2017 16:08:06 -0700 From: Bjorn Andersson To: Srinivas Kandagatla Cc: gregkh@linuxfoundation.org, broonie@kernel.org, alsa-devel@alsa-project.org, sdharia@codeaurora.org, bp@suse.de, poeschel@lemonage.de, treding@nvidia.com, gong.chen@linux.intel.com, andreas.noever@gmail.com, alan@linux.intel.com, mathieu.poirier@linaro.org, daniel@ffwll.ch, jkosina@suse.cz, sharon.dvir1@mail.huji.ac.il, joe@perches.com, davem@davemloft.net, james.hogan@imgtec.com, michael.opdenacker@free-electrons.com, robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kheitke@audience.com, linux-arm-msm@vger.kernel.org, arnd@arndb.de Subject: Re: [Patch v6 1/7] slimbus: Device management on SLIMbus Message-ID: <20171101230806.GD28761@minitux> References: <20171006155136.4682-1-srinivas.kandagatla@linaro.org> <20171006155136.4682-2-srinivas.kandagatla@linaro.org> <20171017062332.GS1165@minitux> <1a1d2777-be69-98ca-afba-0ffd0e3dd80f@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1a1d2777-be69-98ca-afba-0ffd0e3dd80f@linaro.org> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 18 Oct 09:38 PDT 2017, Srinivas Kandagatla wrote: > On 17/10/17 07:23, Bjorn Andersson wrote: > > On Fri 06 Oct 08:51 PDT 2017, srinivas.kandagatla@linaro.org wrote: [..] > > > +static int slim_device_remove(struct device *dev) > > > +{ > > > + struct slim_device *sbdev; > > > + struct slim_driver *sbdrv; > > > + int status = 0; > > > + > > > + sbdev = to_slim_device(dev); > > > + if (!dev->driver) > > > + return 0; > > > + > > > + sbdrv = to_slim_driver(dev->driver); > > > + if (sbdrv->remove) > > > + status = sbdrv->remove(sbdev); > > > + > > > + mutex_lock(&sbdev->report_lock); > > > + sbdev->notified = false; > > > + if (status == 0) > > > + sbdev->driver = NULL; > > > + mutex_unlock(&sbdev->report_lock); > > > + return status; > > > > device_unregister() will call device_del() which will end up in > > __device_release_driver() which will call this function. Upon returning > > from this function the core expect the bus to have cleaned up after the > > dev (normally by calling drv->remove(dev)). > > > > It will completely ignore the return value and continue tearing down the > > rest of the core resources, e.g. three lines down it will > > devres_release_all(). > > > > > > So you have the option of sleeping, while waiting for stuff to be > > aborted/finished and then you need to clean things up. > > > > The slim_device object itself will stick around until all references are > > dropped though. > > So you are suggesting that we make slim_driver remove not return anything? > Yes. Having the opportunity of failing remove() causes driver writers to expect that they can fail, with the result of things not being torn down properly. Note that right after remove() returns devm_* resources will be released, so anything that is not torn down and for some reason later access allocated resources would cause issues. Regards, Bjorn