From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756193AbdETGgu (ORCPT ); Sat, 20 May 2017 02:36:50 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:47100 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753974AbdETGgq (ORCPT ); Sat, 20 May 2017 02:36:46 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Fri, 19 May 2017 23:36:00 -0700 From: Stefan Agner To: Mark Brown Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] regmap: add regmap_debugfs_exit as devres action In-Reply-To: <20170519164616.a4c3ojkfid6oqnts@sirena.org.uk> References: <20170515080827.22905-1-stefan@agner.ch> <20170519164616.a4c3ojkfid6oqnts@sirena.org.uk> Message-ID: <9200d91239d3444609bed00c1597bb15@agner.ch> User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017-05-19 09:46, Mark Brown wrote: > On Mon, May 15, 2017 at 01:08:27AM -0700, Stefan Agner wrote: > >> Instead of manually cleanup regmap_debugfs_exit, use devres action >> to do the cleanup. This also works for external users of >> regmap_attach_dev. > > Why? It's also not clear to me that this will work if something creates > a regmap, frees it and then creates another one on the same device > without a reprobe. There have been a few devices that did that as part > of enumeration of the device, they created a simple regmap to read ID > registers then replaced it with a more complete description of the > actual device they found. > >> This fixes warnings when reloading certain drivers making use of >> regmap_debugfs_exit: >> imx7d-pinctrl 30330000.iomuxc: Failed to create debugfs directory > > How? (and this should be in the changelog.) > The case I observed this is when reprobing drivers/pinctrl/freescale/pinctrl-imx.c. In this driver regmap_attach_dev is used in imx_pinctrl_probe. When the driver gets removed and probed again, the above warning appears since the debugfs entries have not been removed in between... Afaics, at least for external users, using devres for debugfs makes sense since regmap (m) is already using devres... >> @@ -1215,7 +1216,6 @@ void regmap_exit(struct regmap *map) >> struct regmap_async *async; >> >> regcache_exit(map); >> - regmap_debugfs_exit(map); >> regmap_range_exit(map); >> if (map->bus && map->bus->free_context) >> map->bus->free_context(map->bus_context); > > This isn't obviously correct, it reorders the cleanup such that the > debugfs entries will only get removed when the device is removed which > means that the debugfs entries will be hanging around after the regmap > has been deinstantiated. In the common case where it too was allocated > as a managed resource that'll work out but if for some reason it wasn't > allocated as as managed resource then the debug entry will be > dealocated after the regmap. Hm, yeah I see that is a problem. We can drop this change, but then we have to add a private version of regmap_attach_dev which does not add resource managed cleanup of regmap_debugfs_exit... -- Stefan