Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp805355rwe; Wed, 24 Aug 2022 09:12:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR4aGzQ2QLoZH35PAD8nGRGhHYodjg516yk9/E2GnqnGpUjC4dCuPA460pZcI29WMmWxy2Oz X-Received: by 2002:a62:8446:0:b0:535:d9e2:d137 with SMTP id k67-20020a628446000000b00535d9e2d137mr29211089pfd.29.1661357579197; Wed, 24 Aug 2022 09:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661357579; cv=none; d=google.com; s=arc-20160816; b=MO0EklG4D7cfCgbDCTQmTLP//2WWbqcRl47VGzgK6QIsXw5sfzHHrBZpD3Qake26w9 7YHf2AuNyWU3U2FO3Sq9b6I/DSLqPHWPSkNEGPqdDLhecgp5cwU6UvbKzfxlhfzsL1+k jZEuED0jnUDuVx8VdUTQfevX4JQk4jeG+y5V4yucQDk1RecNNJtC1ZdxEN9DvB0yQfEn fovRmomL3A/nMFjMU455YoKEr5wjptcKERk5YtO7TM+qMg6aTyUVH8bamI7x43OGtKCJ 8mDSB0oyXes/DDmic9v+C8tP+coaCo7nCwPnOdy+5XG93ni159/81chnkIMRKwg2KOuk s5/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=KiIFMGOdSQRAgyuh6d1iUT5BtacW3klnbBIVwJD0Oqs=; b=E05fpJS4qrXR4PfIJiJiHHxqqm1u50+vylQFQohJ7yGTkPwM5iSHMwsmvn96VstU9N kN2Zog8mMqqshz7RP24noz5pLvuAhAvbbjT6a4RkTGpyyT3pDMZzCHHayX2Uj60+4Gy3 VysBv758twNoSqEUtTCMIErrpHBfcTMWdKog8UYL8ZdaVfprLOOWCJclqb66QtA9PqEA +lkkZW+927Abb4exPD9CyxsFTUFvD+t5Hrs33ZL2tCwaFI4KtKs3o5285+AO9w/XxdVv W1s/ye+gPWvrl+i7mkFWk31iy2rKyQ6E4a8VuiSSXGMJNhkea4816R6yPfEOZTGV7OSZ Vaqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=kvnRV1ed; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=RrmBPMmC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j11-20020a17090276cb00b00170ad89d371si16213565plt.465.2022.08.24.09.12.47; Wed, 24 Aug 2022 09:12:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=kvnRV1ed; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=RrmBPMmC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237727AbiHXPtD (ORCPT + 99 others); Wed, 24 Aug 2022 11:49:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239916AbiHXPsr (ORCPT ); Wed, 24 Aug 2022 11:48:47 -0400 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D26686C77F for ; Wed, 24 Aug 2022 08:48:27 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id CEE8C32009C8; Wed, 24 Aug 2022 11:48:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 24 Aug 2022 11:48:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1661356106; x=1661442506; bh=KiIFMGOdSQ RAgyuh6d1iUT5BtacW3klnbBIVwJD0Oqs=; b=kvnRV1eddW5m5h4fMiulMBz1dv xnNqkypAWWx0UFAeELpiH5uG7JTd1l4D5DBqX3akRyi7ve4rwihHV82zctXkrcty ZhKjSde99R6jb5JW2titRfm1779ohFweEFVBMj5cn35ZlfzA6z18ECGvEZdl4XwJ LbejOZG6PwvXCYcGMG5+4ik3naJ9iyIEJFEce6YdyVVXzrtWurgBhPH/FoAeLeY+ jDd8Ik0V72ZPMsl7MRfuWNOs2aK/qJSlz5ft/OOjFozTSoF5GOfwsheLJp60AEdd rTXaaq1JyF4HZaImbW/DO7wfP9URJROrIz/a4oLfoRwPovw7K+F97LnafshA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1661356106; x=1661442506; bh=KiIFMGOdSQRAgyuh6d1iUT5BtacW 3klnbBIVwJD0Oqs=; b=RrmBPMmC4K/PIzZBG5PT2o4WofGgwCRlnN9XV9jrjqo2 cdEcKncx6qJfkHc7Wy9UkHpv3y31Ws383TayXakm/YoCcNE81rMYbqX2Ozime0or dpQat30mlDb1aESdrIwWImJ7sQDGOPQl3NQ8y30sBP39CiWNnqKsGJBqALbFLHbd EJ2JVEwCZxuQk5GIe/4hGfNAPM3uUahjtCFvq34kw2BfWWFleWiyCk8xzhp5PFRz ERQ5Pjo1UvGCOgSjMyTRRBsvFc1eLcXZEPxLOfN8EQnBYGr6cpzho48xRPNKDIbn WTaGkknCKVbIcZ36gHcjFpmIf6PODgI39bJm7fQNOQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdejuddgleehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeetfefffefgkedtfefgledugfdtjeefjedvtddtkeetieffjedvgfehheff hfevudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 24 Aug 2022 11:48:25 -0400 (EDT) Date: Wed, 24 Aug 2022 17:48:23 +0200 From: Maxime Ripard To: Danilo Krummrich Cc: daniel@ffwll.ch, airlied@linux.ie, tzimmermann@suse.de, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH drm-misc-next v2 2/4] drm/vc4: plane: protect device resources after removal Message-ID: <20220824154823.qu3tdwypg5o3ci4z@houat> References: <20220819110849.192037-1-dakr@redhat.com> <20220819110849.192037-3-dakr@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="i6p2xirgmwjujatv" Content-Disposition: inline In-Reply-To: <20220819110849.192037-3-dakr@redhat.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --i6p2xirgmwjujatv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 19, 2022 at 01:08:47PM +0200, Danilo Krummrich wrote: > (Hardware) resources which are bound to the driver and device lifecycle > must not be accessed after the device and driver are unbound. >=20 > However, the DRM device isn't freed as long as the last user closed it, > hence userspace can still call into the driver. >=20 > Therefore protect the critical sections which are accessing those > resources with drm_dev_enter() and drm_dev_exit(). >=20 > Fixes: 9872c7a31921 ("drm/vc4: plane: Switch to drmm_universal_plane_allo= c()") > Signed-off-by: Danilo Krummrich > --- > drivers/gpu/drm/vc4/vc4_plane.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) >=20 > diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_pl= ane.c > index eff9c63adfa7..c46acb770036 100644 > --- a/drivers/gpu/drm/vc4/vc4_plane.c > +++ b/drivers/gpu/drm/vc4/vc4_plane.c > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1219,6 +1220,10 @@ u32 vc4_plane_write_dlist(struct drm_plane *plane,= u32 __iomem *dlist) > { > struct vc4_plane_state *vc4_state =3D to_vc4_plane_state(plane->state); > int i; > + int idx; > + > + if (!drm_dev_enter(plane->dev, &idx)) > + goto out; > =20 > vc4_state->hw_dlist =3D dlist; > =20 > @@ -1226,6 +1231,9 @@ u32 vc4_plane_write_dlist(struct drm_plane *plane, = u32 __iomem *dlist) > for (i =3D 0; i < vc4_state->dlist_count; i++) > writel(vc4_state->dlist[i], &dlist[i]); > =20 > + drm_dev_exit(idx); > + > +out: > return vc4_state->dlist_count; > } > =20 > @@ -1245,6 +1253,7 @@ void vc4_plane_async_set_fb(struct drm_plane *plane= , struct drm_framebuffer *fb) > struct vc4_plane_state *vc4_state =3D to_vc4_plane_state(plane->state); > struct drm_gem_dma_object *bo =3D drm_fb_dma_get_gem_obj(fb, 0); > uint32_t addr; > + int idx; > =20 > /* We're skipping the address adjustment for negative origin, > * because this is only called on the primary plane. > @@ -1252,12 +1261,17 @@ void vc4_plane_async_set_fb(struct drm_plane *pla= ne, struct drm_framebuffer *fb) > WARN_ON_ONCE(plane->state->crtc_x < 0 || plane->state->crtc_y < 0); > addr =3D bo->dma_addr + fb->offsets[0]; > =20 > + if (!drm_dev_enter(plane->dev, &idx)) > + return; > + > /* Write the new address into the hardware immediately. The > * scanout will start from this address as soon as the FIFO > * needs to refill with pixels. > */ > writel(addr, &vc4_state->hw_dlist[vc4_state->ptr0_offset]); > =20 > + drm_dev_exit(idx); > + You did change the CRTC patch, but the comment to protect the entire function also applies to this one. Maxime --i6p2xirgmwjujatv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYwZIRwAKCRDj7w1vZxhR xTpMAP9QqYSv8ty8je48B2HuywFGJE+Q2WGNAW/paVlqkHD0WwD/XgOG/VA+mckd g+GkI3JRlnAhkCqVRyReiq/t0DFeagk= =OEZa -----END PGP SIGNATURE----- --i6p2xirgmwjujatv--