Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2207135imu; Thu, 29 Nov 2018 00:58:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/VFtxgxHqHvQMI24IR0qBqdHi7NNtgLlbVkmbh8CgWKFO5mUmxPKTCX3zusiqH/+X0JMiFC X-Received: by 2002:a17:902:2:: with SMTP id 2mr649779pla.228.1543481902255; Thu, 29 Nov 2018 00:58:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543481902; cv=none; d=google.com; s=arc-20160816; b=ddf+HV1FbcT/LUUiWZ5ybqoxabii5garH7jdYwwKrPQhVUkwhQk0AU+X+PsZ3ny7sf cC2Z0BWZzoTlphWSSdhiBGJyRusVlVhZkuwh+jbojNcGmjLVNw3ica9CaPVeJhyze1Im zkkjJyAv86U4LAqQKUOzjnGeOZ5t6w/5L9qDbAeFwsbJVVPhUjWEnFpwLrgzs+eTW+NO lekV7wcP+6f+HrO+qZq4uBwxGuoZhVVSjy1s+rYeaQyV3Ckjz/LV0JfgU5NQT6Btx5X7 iGQVbH5V7SgOsK05+1Oon+xjzMoOzWgnrjRtJr288UkuGCCmGihoG9sGUMHwmcOZfBmx WnAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=qWmS5X3oWUwyLNW9cMpNUuMHuMWFjeAl5OoIeXLn3BY=; b=nU43AtWIDLgusYhOPd8It2Z5C43a8PvHWldS1PHsBZvXPup6aw/Hp2/HoZ/jnO3Bn6 AeLyb1f7zKj/eYH7d1Fxmf9Yi9k+hegaMOG2zpLCyBgMP+A1c2IsDnqnJY9KmmPEpmib 2bL7+6JofdAzKqNiXQoOlGxdSfN0UaaMOUvQSBuDYl513zFMfgrmezP/Bvhee+Ak8Crp 9BVlEdc8e8GVcbHesUp2aQCrFH1B42qF91MLa9S9urlLfbYUWr9TBa4UwyeNEtnv9Uvc F9gQ8oSg6o1sGwV2wj58xt65PFvsgHdpvPeO59HhWhoOqbpeaWkazvbINh3RcJK14BDY /uow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b="NKx1Gz/q"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si1438323pli.438.2018.11.29.00.58.07; Thu, 29 Nov 2018 00:58:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b="NKx1Gz/q"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726841AbeK2UBp (ORCPT + 99 others); Thu, 29 Nov 2018 15:01:45 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:53536 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726579AbeK2UBp (ORCPT ); Thu, 29 Nov 2018 15:01:45 -0500 Received: by mail-it1-f194.google.com with SMTP id g85so2439037ita.3 for ; Thu, 29 Nov 2018 00:57:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qWmS5X3oWUwyLNW9cMpNUuMHuMWFjeAl5OoIeXLn3BY=; b=NKx1Gz/qnclh1q+jHuyh3xLQoheg9CKQisn6NytxcQzEe1UPev2p9g9s7/zq+JDfD4 7N0IkwiCMMS9bMFxpIjpmmtizqsIK4Os2iR+z9I5FBFXv7WOGSfVZMbVBwdsTUYhi4BW xy49n8LTqPZfZij6ku//3hk2pcKgCz5KRoOak= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qWmS5X3oWUwyLNW9cMpNUuMHuMWFjeAl5OoIeXLn3BY=; b=AgiwomQw0QbbolTJxGNWYgjHqOmD9/hTy2fi08JQkFtRRxqTd5Abf0e7ZywvWhGyQ+ zMJlrML9rr3S878ZuEnZzGmQiL0kpHznF5yVLCpw9GZmYVlsjW0RhKGrEzpf0FN4oQsq HaOokFeQrUi1Bj0C1yYt6ffEVI7/ugPZR7wro47lEtLzspdE5p+U/gYR3135Zh+kSzWC 4j4QlR52Gm6A4exm6oMOX13lG5vGyz59ZT298rdDObdb69nCWwHi6uRZaBsMxFQKTJRD gqA6fITUv+U5NooztDe3R/lIFwF0pRORAnZIrYTAIqQT0S0HFKwnAAlIqlyasc1O8mjP 8HSw== X-Gm-Message-State: AA+aEWbpmFfJSdRmjiQeKGylDoEOQVAG2H2TL7vCo8bZWpXorjFb+/Ko +1GZdbshanelr1TLvz9+d56+RnjkU4r8bTtFMxQwuQ== X-Received: by 2002:a02:85ae:: with SMTP id d43mr490723jai.70.1543481825119; Thu, 29 Nov 2018 00:57:05 -0800 (PST) MIME-Version: 1.0 References: <3350c5dd5ea08c71e4769ea3801290e7f9238a6c.1541397462.git.sbobroff@linux.ibm.com> <20181129020034.GA10328@tungsten.ozlabs.ibm.com> In-Reply-To: <20181129020034.GA10328@tungsten.ozlabs.ibm.com> From: Daniel Vetter Date: Thu, 29 Nov 2018 09:56:53 +0100 Message-ID: Subject: Re: [PATCH 2/2] drm/ast: Fix connector leak during driver unload To: sbobroff@linux.ibm.com Cc: "airlied@gmail.com" , Dave Airlie , Dave Airlie , Linux Kernel Mailing List , dri-devel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 29, 2018 at 9:05 AM Sam Bobroff wrote: > > On Thu, Nov 29, 2018 at 09:40:53AM +1000, Dave Airlie wrote: > > On Mon, 5 Nov 2018 at 15:59, Sam Bobroff wrote: > > > > > > When unloading the ast driver, a warning message is printed by > > > drm_mode_config_cleanup() because a reference is still held to one of > > > the drm_connector structs. > > > > > > Correct this by calling drm_framebuffer_remove() in > > > ast_fbdev_destroy(). > > > > > > Signed-off-by: Sam Bobroff > > > --- > > > drivers/gpu/drm/ast/ast_fb.c | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c > > > index 0cd827e11fa2..655372ea81e9 100644 > > > --- a/drivers/gpu/drm/ast/ast_fb.c > > > +++ b/drivers/gpu/drm/ast/ast_fb.c > > > @@ -263,6 +263,10 @@ static void ast_fbdev_destroy(struct drm_device *dev, > > > { > > > struct ast_framebuffer *afb = &afbdev->afb; > > > > > > + /* drm_framebuffer_remove() expects us to hold a ref, which it > > > + * will drop, so take one: */ > > > + drm_framebuffer_get(&afb->base); > > > + drm_framebuffer_remove(&afb->base); > > > > This doesn't seem corret, no other driver does this pattern, and I > > can't believe ast is special here. > > > > The get just doesn't make sense. > > Thanks for having a look at this, as I said in the cover letter I was > concerned that it might not be a good fix. > > But the AST driver does seem to be special (or just old?) because it > embeds the drm_framebuffer directly into ast_fbdev and (almost all) > other drivers dynamically allocate and reference count theirs. > > The drm_framebuffer_get() certainly looks weird but it is there in order > to cause drm_framebuffer_remove() to call legacy_remove_fb(), which it > won't do unless the refcount is at least 2. (And because the > drm_framebuffer isn't dynamically allocated in this case we don't really > care about the reference count anyway.) > > An alternative might be to call legacy_remove_fb() directly, but it's > declared static. Do you think it would be better to expose it and call > it directly from the AST driver code? Or is there some other better way > to put the drm_connectors? Your problem isn't the dynamic fb vs. embedded fb for fbdev (you're already using drm_framebuffer_unregister_private to handle that). Your problem is you're not shutting down stuff on driver unload, which means the fb is still in use. drm_atomic_helper_shutdown() takes care of that for atomic drivers. No idea anymore what to do for legacy code, probably need to open code a shutdown sequence. Definitely not the above. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch