Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6377779imu; Sun, 2 Dec 2018 16:47:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/X2SlChIfVxhO4hDXT3LddoLRvVDLxTePqnW5O3abSxX+uza2i6vH8YwJikZTBPkRBZnikG X-Received: by 2002:a17:902:1a8:: with SMTP id b37-v6mr13988812plb.314.1543798046581; Sun, 02 Dec 2018 16:47:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543798046; cv=none; d=google.com; s=arc-20160816; b=1AAhLQdEiV6JFIZiLgYC02jy0bzwYZycJxpOcUVkL1NCi6Sf85xOxfqJK05YX640kZ t+B1dB7CMxSHRrmuIhAbcatUrx06YzB/AQo0pIy80UdZ0uNy8OsoUlWmKTi/qGE0YhUn b0m9nOF/6hjP03FZWiG5exp+IZ24HlPZhQICY4+O9CBh7PXVegMupSnZU0b8T7bVBeDA 1ZynfoYqRr631+VV8pYwfyHs4hgiLM6D2ZNER6ZFNsLuTYqhzdZ4ggIp9Z92gjASwewY VUKytZP/SxCYc9TYKdiJwAcqGpCfyhM98m05wIAWyyKaKB3YwxaWfaQYU7PczY5NPFZu CuHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:subject:to:from:date; bh=CgKiSARlvvMV3uQe0nYCKZGRLlmACz5FnpYPGvMEe0w=; b=ckMydYkUmbrfEkKYQrZ3nu/0B93PosHumFmo6lWxoiP3GMtphub6BEcNx+mcPZxw2Y VWYSmluGEUq9CBqaJOg4LsVNizL18jWl3SlIwDwi7ST34zXm5uwgGvddqZBJ6ddJj1Py Uo3xWWZAaHZRBE7oKbPJzj3qDj5JQPfMymwGPSa2Fw+n34BPbQcaKDJ8MBOBRHtcoqWf bLGbDrl5vEkOw6VreSTdX2nUsO3JYCGdfZXs/k16qp+LA7AQugAx7gcyeEPX23V6dxaX OJvnHYLULU5Qmz5gopiPj+HSyqKjxUfaYruirO1gGBkCkQxT2GMvmLOaIsmfXlScGAJT /EZA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t11si11418524plo.293.2018.12.02.16.47.09; Sun, 02 Dec 2018 16:47:26 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725897AbeLCAqe (ORCPT + 99 others); Sun, 2 Dec 2018 19:46:34 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41432 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725785AbeLCAqd (ORCPT ); Sun, 2 Dec 2018 19:46:33 -0500 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wB30ht3j019992 for ; Sun, 2 Dec 2018 19:46:29 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2p4rwnjdab-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 02 Dec 2018 19:46:29 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 3 Dec 2018 00:46:27 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 3 Dec 2018 00:46:25 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wB30kOhL49086708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 3 Dec 2018 00:46:24 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46B2D4C040; Mon, 3 Dec 2018 00:46:24 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A07954C04E; Mon, 3 Dec 2018 00:46:23 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 3 Dec 2018 00:46:23 +0000 (GMT) Received: from tungsten.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 363DBA0129; Mon, 3 Dec 2018 11:46:20 +1100 (AEDT) Date: Mon, 3 Dec 2018 11:46:19 +1100 From: Sam Bobroff To: "airlied@gmail.com" , Dave Airlie , Dave Airlie , Linux Kernel Mailing List , dri-devel Subject: Re: [PATCH 2/2] drm/ast: Fix connector leak during driver unload References: <3350c5dd5ea08c71e4769ea3801290e7f9238a6c.1541397462.git.sbobroff@linux.ibm.com> <20181129020034.GA10328@tungsten.ozlabs.ibm.com> <20181130001750.GA6776@tungsten.ozlabs.ibm.com> <20181130094108.GT21184@phenom.ffwll.local> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FL5UXtIhxfXey3p5" Content-Disposition: inline In-Reply-To: <20181130094108.GT21184@phenom.ffwll.local> User-Agent: Mutt/1.9.3 (2018-01-21) X-TM-AS-GCONF: 00 x-cbid: 18120300-4275-0000-0000-000002EB0973 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18120300-4276-0000-0000-000037F809AE Message-Id: <20181203004618.GA11552@tungsten.ozlabs.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-12-02_16:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812030006 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 30, 2018 at 10:41:08AM +0100, Daniel Vetter wrote: > On Fri, Nov 30, 2018 at 11:17:51AM +1100, Sam Bobroff wrote: > > On Thu, Nov 29, 2018 at 09:56:53AM +0100, Daniel Vetter wrote: > > > 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_d= evice *dev, > > > > > > { > > > > > > struct ast_framebuffer *afb =3D &afbdev->afb; > > > > > > > > > > > > + /* drm_framebuffer_remove() expects us to hold a ref, w= hich 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 w= as > > > > 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 r= eally > > > > 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? > > >=20 > > > 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. > > >=20 > > > No idea anymore what to do for legacy code, probably need to open code > > > a shutdown sequence. Definitely not the above. > > > -Daniel > >=20 > > Well, it looks like drm_crtc_force_disable_all() would also do the job, > > and from looking at nouveau_display_fini() it's used there as an > > alternative to drm_atomic_helper_shutdown(). >=20 > Ah right, I tried looking for that one but didn't find it with a quick > scan. > =20 > > Would it be reasonable to call that at the start of > > ast_fbdev_destroy() instead? (Testing shows that it does allow the > > drm_connector to be released. Is it enough/correct though?) >=20 > Yes. > -Daniel Great, I'll post a v2 with that change. Cheers, Sam. --FL5UXtIhxfXey3p5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEELWWF8pdtWK5YQRohMX8w6AQl/iIFAlwEfNMACgkQMX8w6AQl /iK1Egf/UwcLHeTtSzAGD6HEgpsNauIflJieagrSKOQJ4jllYkpOeg7RLOV856HA OGu14+gkLHhSwrELl6kMBGQSLnxigDCaa+JzI3kUjQVe8dPC/hnWZSZbXGk82DaD Ya6NVpcpm4wtCpM1gpUqlTftUt0GxOxwycmirq9zde35NoI0ZXLrQRuMUhxnkcYI hvnAWyezV4D9HFp7CgP8epTESGtOuHqEnfe+n+tj2Mk6lBuu60VuF51ymeGbcvZ9 sJXcQ45PRygRltmM12GbpzSyFk8QTPqBJ/3BM9gikF2uGjjtcNWKiXJx8vavhE7F VbdBIogr+MrJUgw7uKU9gc0I79Gm0Q== =4k2e -----END PGP SIGNATURE----- --FL5UXtIhxfXey3p5--