Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1157602yba; Thu, 9 May 2019 11:41:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2sYA4KcIDwqFn0/LH7dRWruqCB9i4rs15z5Bl/tk5W7uOhkvOcFngzwZAnocYdoKwZ3su X-Received: by 2002:a63:c94a:: with SMTP id y10mr7648757pgg.168.1557427306504; Thu, 09 May 2019 11:41:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557427306; cv=none; d=google.com; s=arc-20160816; b=UpqiEKYujibqe0uN0nPl+lOXOyeqJzrVMNSmuNLlJd7z+LKDYsZZV3Fnfo/E+UUJUb 4j0HNKEb11/hvAUH5TAHqYE6PC+/w5qu3uJV3miFaj2Cd9/G1NhkZhepV2c705zdzrKM He/C+vt/F7ep+qyyOhtXuchSKxKxSj45ef3A9cTjwCCkxqqMkmOM1p36YflD2WGZumtu BBHmqtmCA7ILf2XyENL1Z+GH4CVMmU4xZl1GzIWtauB6OfzXZM5Oz1mzbMnmTTCkdC2R Eg2bfnSAqYPaNGXPO0MXfYPst1rG0SADOULMPPTO59zqhIDmR+pCMQ9K03NjT4kT6aLu 6bOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from; bh=a1B70P6oOf2LNjn9YYejqzKKBBXQTzCPeqQaNtCiZM0=; b=z+TeJwWqd6DQ/ZNoZTBewGCzGaHeJQi8rjrfBt/mXWiug9DNrmQ2VCXjRS2hhHBm40 A968sf8ov1wqcNM9YibNXVt0nO1q+puUFr4iWNIcFkyajzuUiaYrCfYoyPhTDT0Ke1Qi ZG7nQo57xw0fBAWjX2TZLud1r+HfmDQsKFN5qoRnW/27WxbWLdyEAx2eCtVP3AlLFKQL hzVO7a94ZNVMNNjfhp/ObtmMTPfadBWmjoKEyEK0sXqAEfLpt8QADLU/PB7qGqerDs/b yK53fzkV0KvPDUnpRtmi6lrw+Lk8Wf6E8bJIoffgK5DYk3InDfc5iqJ5SjQZ7rEUptY8 6HOg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si4008079plz.198.2019.05.09.11.41.28; Thu, 09 May 2019 11:41:46 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726716AbfEISjV (ORCPT + 99 others); Thu, 9 May 2019 14:39:21 -0400 Received: from anholt.net ([50.246.234.109]:37370 "EHLO anholt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726632AbfEISjV (ORCPT ); Thu, 9 May 2019 14:39:21 -0400 Received: from localhost (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 747F910A34BA; Thu, 9 May 2019 11:39:20 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at anholt.net Received: from anholt.net ([127.0.0.1]) by localhost (kingsolver.anholt.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Y9nQtU846ddV; Thu, 9 May 2019 11:39:19 -0700 (PDT) Received: from eliezer.anholt.net (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 1F94810A33E6; Thu, 9 May 2019 11:39:19 -0700 (PDT) Received: by eliezer.anholt.net (Postfix, from userid 1000) id A737D2FE3AA9; Thu, 9 May 2019 11:39:18 -0700 (PDT) From: Eric Anholt To: Paul Kocialkowski , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: David Airlie , Daniel Vetter , Maxime Ripard , Eben Upton , Thomas Petazzoni , Paul Kocialkowski Subject: Re: [PATCH v8 4/4] drm/vc4: Allocate binner bo when starting to use the V3D In-Reply-To: <20190503081242.29039-5-paul.kocialkowski@bootlin.com> References: <20190503081242.29039-1-paul.kocialkowski@bootlin.com> <20190503081242.29039-5-paul.kocialkowski@bootlin.com> User-Agent: Notmuch/0.22.2+1~gb0bcfaa (http://notmuchmail.org) Emacs/26.1 (x86_64-pc-linux-gnu) Date: Thu, 09 May 2019 11:39:17 -0700 Message-ID: <87r2973222.fsf@anholt.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Paul Kocialkowski writes: > The binner BO is not required until the V3D is in use, so avoid > allocating it at probe and do it on the first non-dumb BO allocation. > > Keep track of which clients are using the V3D and liberate the buffer > when there is none left, using a kref. Protect the logic with a > mutex to avoid race conditions. > > The binner BO is created at the time of the first render ioctl and is > destroyed when there is no client and no exec job using it left. > > The Out-Of-Memory (OOM) interrupt also gets some tweaking, to avoid > enabling it before having allocated a binner bo. > > We also want to keep the BO alive during runtime suspend/resume to avoid > failing to allocate it at resume. This happens when the CMA pool is > full at that point and results in a hard crash. > > Signed-off-by: Paul Kocialkowski > @@ -313,6 +321,49 @@ static int bin_bo_alloc(struct vc4_dev *vc4) > return ret; > } >=20=20 > +int vc4_v3d_bin_bo_get(struct vc4_dev *vc4, bool *used) > +{ > + int ret =3D 0; > + > + mutex_lock(&vc4->bin_bo_lock); > + > + if (used && *used) > + goto complete; > + > + if (used) > + *used =3D true; > + > + if (vc4->bin_bo) { > + kref_get(&vc4->bin_bo_kref); > + goto complete; > + } > + > + ret =3D bin_bo_alloc(vc4); I think this block wants to be: if (vc4->bin_bo) kref_get(&vc4->bin_bo_kref); else ret =3D bin_bo_alloc(vc4); if (ret =3D=3D 0 && used) *used =3D true; (so we don't flag used if bin_bo_alloc fails) If you agree, then the series is: Reviewed-by: Eric Anholt > + > +complete: > + mutex_unlock(&vc4->bin_bo_lock); > + > + return ret; > +} --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE/JuuFDWp9/ZkuCBXtdYpNtH8nugFAlzUc9UACgkQtdYpNtH8 nui+7A//dYFvEu23z/u7C7jPsCdV5Pe5lH1XBUv3QPsIOcO5V868i7nOqWB7XdW7 CVfm9p3RkMGk5KkarXSxPqnkP6HEsOUEalDLHkqeljij6Il7PZhjlE/8bq59F1PY xlTelmR0KqffrvaTErXR8rbkOe0HCRyyhoGP1FDu8R5PMc79MEYOyayhiIniuAjh Ec6I/8msFgls3ojw93sFxf0H+TmcE8sHUJoT0/JAfeDFi+QDnB9uxcEZt9xZQGP5 0XK8SQn9Cz2KfL9DLGSFLIM/5QVhpoxCbRohPXVPuO953oyn+eSxnUwX8Ymusz3S xr6VZRnPjeVf5Reb9GTkUMESdOR3WCnmuSA1jpuQqA/EBPU9XO7d/q/pascozGvJ AszjT5pMO9uPmcbGerq0CBkAHe5XbS5CkLTYpgeXD+PbFwsplKpGL42q1XyL8NMy 5dANWecHDr3bRekX8Qy4ytE6e7X4hmfrNEj7klluotw39alOk/+WHBMbOYnsPPkq y6jaanE14J3GBlz7W6+YIYuGG5m2ITCc4+gkkcHcdnjKG2iBAMZ/0qg44KfORYxS +PzryEx67Fm94Ihjb9wr4u4wYI2aQuhGAsl7F52v5Atfx0pQHp3Y9s7auk3c36eo 9icaWzFBdqKBk5wz5wMTgpcRnJsX/witly1fxBuKb4/avZ60E5E= =qaUS -----END PGP SIGNATURE----- --=-=-=--