Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752815AbdHGJZN (ORCPT ); Mon, 7 Aug 2017 05:25:13 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:36586 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752611AbdHGJZL (ORCPT ); Mon, 7 Aug 2017 05:25:11 -0400 Date: Mon, 7 Aug 2017 11:25:07 +0200 From: Daniel Vetter To: Noralf =?iso-8859-1?Q?Tr=F8nnes?= Cc: Ilia Mirkin , Eric Anholt , Daniel Vetter , Thierry Reding , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , Laurent Pinchart Subject: Re: [PATCH v5 2/6] drm/bridge: Add a devm_ allocator for panel bridge. Message-ID: <20170807092507.b735ribfpjm6oejk@phenom.ffwll.local> Mail-Followup-To: Noralf =?iso-8859-1?Q?Tr=F8nnes?= , Ilia Mirkin , Eric Anholt , Daniel Vetter , Thierry Reding , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , Laurent Pinchart References: <20170718210510.12229-1-eric@anholt.net> <20170718210510.12229-2-eric@anholt.net> <2023170.2CE3xBA9bq@avalon> <87zibfqd1u.fsf@eliezer.anholt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Operating-System: Linux phenom 4.11.0-2-amd64 User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2381 Lines: 52 On Sat, Aug 05, 2017 at 12:59:07PM +0200, Noralf Tr?nnes wrote: > (I had to switch to Daniel's Intel address to get this sent) > > Den 05.08.2017 00.19, skrev Ilia Mirkin: > > On Fri, Aug 4, 2017 at 4:43 PM, Eric Anholt wrote: > > > Laurent Pinchart writes: > > > > > > > Hi Eric, > > > > > > > > (CC'ing Daniel) > > > > > > > > Thank you for the patch. > > > > > > > > On Tuesday 18 Jul 2017 14:05:06 Eric Anholt wrote: > > > > > This will let drivers reduce the error cleanup they need, in > > > > > particular the "is_panel_bridge" flag. > > > > > > > > > > v2: Slight cleanup of remove function by Andrzej > > > > I just want to point out that, in the context of Daniel's work on hot-unplug, > > > > 90% of the devm_* allocations are wrong and will get in the way. All DRM core > > > > objects that are accessible one way or another from userspace will need to be > > > > properly reference-counted and freed only when the last reference disappears, > > > > which could be well after the corresponding device is removed. I believe this > > > > could be one such objects :-/ > > > Sure, if you're hotplugging, your life is pain. For non-hotpluggable > > > devices, like our SOC platform devices (current panel-bridge consumers), > > > this still seems like an excellent simplification of memory management. > > At that point you may as well make your module non-unloadable, and > > return failure when trying to remove a device from management by the > > driver (whatever the opposite of "probe" is, I forget). Hotplugging > > doesn't only happen when physically removing, it can happen for all > > kinds of reasons... and userspace may still hold references in some of > > those cases. > > If drm_open() gets a ref on dev->dev and puts it in drm_release(), > won't that delay devm_* cleanup until userspace is done? No. drm_device is the thing that is refcounted for userspace references like open FD (we're not perfect about it, e.g. sysfs and dma-buf/fence don't). devm_ otoh is tied to the lifetime of the underlying device, and that one can get outlived by drm_device. Or at least afaiui, devm_ stuff is nuked on unplug, and not when the final sw reference of the struct device disappears. Not sure tough, it's complicated. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch