Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1437817yba; Tue, 2 Apr 2019 08:52:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwmvbXAM4m7WRMNvmf5zLiLUcNRnpMcdyJS7Vji8JXI+Vh6lnBatpF0oIz/ZcBgSQAFY4P X-Received: by 2002:aa7:8a92:: with SMTP id a18mr70040690pfc.218.1554220339175; Tue, 02 Apr 2019 08:52:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554220339; cv=none; d=google.com; s=arc-20160816; b=jXI9rMmDLAhpC2ZxSBhoRIpKPkPKF2/CiW+p0+yYQ41IXNbYFO6B2nOZLFuNQUfh3l zmWEgOKbhtoKlavmeen/MLrRFMO82nQ8nI57y8aFdVyAeSWIvGwQQJOdDUA85aU5kBw/ gGeK4RSEdW8XDBgmqfdw3H9yJwd8Baz9l8d61h+uB2/CjW15hxPn+0bI8+RVi/4jRXMt KxLPj5M4KiiBndW2ytwHAkLII78ZHWSUWNzYadJuEO8pBcIxGioryrhZ3jwtoFybWKbL Cux9ASRvHihRp7tEG+bWJm6YMLQAp5k70hHGNuuvpcQfo1x+qSi8CB2b8j6aBZ0R5p2z Bg4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8k4k1n05seAp7pzG9Pr/za4xL3oyUKKuBSjuKYVe0BI=; b=hXHe37YmqgRVxCzPKiFpCQGyYyuTFpOo8FdO8o883VMLyERMrYjzkhXFVxazErm9+N uEKhAi24QFYX9k0Yltyinezcp5b1OzErlL5gUE4jsKSDuAhjsE1ND8y7oH1pUVAPOUwY VNvIHbeu43nMtCWp8lpFfnLq+FHUlZMMxlLPvzLKCUtMMK4AFSlYLh5WcRjNPRLCsUSP 0jWnplsrxED/uxmvYQTu8C6It5ilu2PmYRTY18LRwPXc6sULMCjeWVz5CM2pZ4z/VBkU roAKonw+iS+G/to5eN5Z6adMqP955MJC+CNInSFcjF+HOX0fjnuHnX4Xo+TmKq+Fxhnq Pcwg== 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 b16si8449331pgb.501.2019.04.02.08.52.04; Tue, 02 Apr 2019 08:52:19 -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 S1732221AbfDBOvU (ORCPT + 99 others); Tue, 2 Apr 2019 10:51:20 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:59567 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726458AbfDBOvT (ORCPT ); Tue, 2 Apr 2019 10:51:19 -0400 X-Originating-IP: 90.88.30.125 Received: from localhost (aaubervilliers-681-1-89-125.w90-88.abo.wanadoo.fr [90.88.30.125]) (Authenticated sender: maxime.ripard@bootlin.com) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 962731BF20C; Tue, 2 Apr 2019 14:51:14 +0000 (UTC) Date: Tue, 2 Apr 2019 16:51:14 +0200 From: Maxime Ripard To: Emil Velikov Cc: Daniel Vetter , David Airlie , Maarten Lankhorst , Sean Paul , Mauro Carvalho Chehab , Sakari Ailus , "Linux-Kernel@Vger. Kernel. Org" , ML dri-devel , Paul Kocialkowski , Hans Verkuil , Laurent Pinchart , Thomas Petazzoni , linux-media@vger.kernel.org Subject: Re: [RFC PATCH 01/20] drm: Remove users of drm_format_num_planes Message-ID: <20190402145114.bpt5atxxooufgzz5@flea> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lgdfh3o7stmf4lnx" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --lgdfh3o7stmf4lnx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Emil, On Tue, Apr 02, 2019 at 10:43:31AM +0100, Emil Velikov wrote: > On Tue, 19 Mar 2019 at 21:57, Maxime Ripard wrote: > > drm_format_num_planes() is basically a lookup in the drm_format_info table > > plus an access to the num_planes field of the appropriate entry. > > > > Most drivers are using this function while having access to the entry > > already, which means that we will perform an unnecessary lookup. Removing > > the call to drm_format_num_planes is therefore more efficient. > > > > Some drivers will not have access to that entry in the function, but in > > this case the overhead is minimal (we just have to call drm_format_info() > > to perform the lookup) and we can even avoid multiple, inefficient lookups > > in some places that need multiple fields from the drm_format_info > > structure. > > > > I'm not fan of the duplicated loop-ups either. > > > -int drm_format_num_planes(uint32_t format) > > -{ > > - const struct drm_format_info *info; > > - > > - info = drm_format_info(format); > > - return info ? info->num_planes : 1; > > -} > > -EXPORT_SYMBOL(drm_format_num_planes); > > - > > The existing users are not updated to cater for the num_planes != 0 > case... Which seems non-existent scenario since all the current format > descriptions have 1+ planes. > Should we add a test (alike the ones in 6/20) to ensure, that no entry > has 0 planes? Is it even worth it or I'm a bit too paranoid? > > The above comments apply to 2/20. I'm not entirely sure what you mean. num_planes is returned as is in the drm_format_num_planes function and it doesn't check for the num_planes value itself. That being said, we could definitely add some more tests to check that we haven't falling into the situation you describe, since most of the drivers indeed don't check for that value themselves. But that seems pretty othorgonal to me? > With the name suggestions by Paul, patches 1 to 5 (incl.) are: > Reviewed-by: Emil Velikov Thanks! Maxime -- Maxime Ripard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com --lgdfh3o7stmf4lnx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXKN24gAKCRDj7w1vZxhR xdcIAPwMegTv/UcHRA+TAB4ezclPNbm+1U/NJzXvnXyZ2shdqAEA7A05cNikgqEW zGKsikrWNgK28tqwL+rYgk+cLDOVKAA= =PIGw -----END PGP SIGNATURE----- --lgdfh3o7stmf4lnx--