Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1371178yba; Thu, 4 Apr 2019 09:25:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBAkzu+MI3tSwmSxcusecP/qkBXK/vF289XKZCvB8CRmTbCw/lNfJFRpmc3dFSy0agld8s X-Received: by 2002:a62:7089:: with SMTP id l131mr7002001pfc.158.1554395120598; Thu, 04 Apr 2019 09:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554395120; cv=none; d=google.com; s=arc-20160816; b=Oy44tcEEI4To36mZXeO/0Wl9kW19subVtTqUk1XlcPrVIK4Mscu3PmDdvmnRedK4Ie L+Xp+Gn1vvjKvKEjzTJ/TMrusuLkKw6T/cknw02u0ko6jt0QIy/qN8u3icTsqIZUoSvU Cw1J83jTKM9xBxG2RxMcrbStr+ecQoH2XW5hkF4Y8HWv8kj0LUsUeDihvJoTgn3ejwVI ZNQQV7yctT0S7TGTT2S1Trcz+S9+eXhg9ip7HpExMkOQFBFZJf71s6cB9TFt75vSeL5I L1M2gfNO6Nag/XR7M51gAwlK2cxRrWI87jDT2zEdYlgeow2gajYwK+WecuIhf4xVfTy2 nDKQ== 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=4AkQLLIUIPYpV/JS7s3jTAzAGf+1v6pVPd+k37Rstdw=; b=nlOD0XvDMJ32HvkSCjf4d0Yao4/CO2FVcEo5Nj0lPcQ/w1s8mwv0kRyLCi1T/yoz0l 5uWgUQ6yHf1qoCwG0PNef7bMvNOkTFy1yKnlQxoHEVysC6ThdXc3Glh+U0lTzOaaqL5/ XOi5PtdEeHppxaLH4Lq0zCMWvjok/A9CENdkajx7COEtrzcLC8EGUid2OE6J9u/RjTrY fnLsdOmf0DjA9rnSsXiglAAJCw0TmSdptFV87TVK1YobPHHXYjCI8Rd1DsvHcXKLYQsi LNGaDe4VVYw7EklToh+DqkN5IzlOKQLNAV6TpWQzrTaV6zR1vB0v+9Qhp1ifPXTvRqkK ViSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hE7kSjzt; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si18021039pfc.71.2019.04.04.09.25.04; Thu, 04 Apr 2019 09:25:20 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hE7kSjzt; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729158AbfDDQYG (ORCPT + 99 others); Thu, 4 Apr 2019 12:24:06 -0400 Received: from mail-vs1-f65.google.com ([209.85.217.65]:33262 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727051AbfDDQYG (ORCPT ); Thu, 4 Apr 2019 12:24:06 -0400 Received: by mail-vs1-f65.google.com with SMTP id a190so1737756vsd.0; Thu, 04 Apr 2019 09:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4AkQLLIUIPYpV/JS7s3jTAzAGf+1v6pVPd+k37Rstdw=; b=hE7kSjztgwz0MC81/GIIudK1yRuB2MB5Y5TeYbNvTO6g/0pyPzGhuXpjmr56P9rklO h7AHxEG8CysYexiruRj5kkSKQlJgQHUMaJ5rq8sKgfcfB4yTr4tNFUX/h3aD0amYg4qY 77Qst/drCl1J0cEvN6tSLpyBctCjsJORMSgLFfKal9vbUtrh9ixKN0cCafn2e6yUNaqB ff5G3aYJDcnvumoMQ36+bBVl9lAtwul8/YTzB1TcF3UiKYGkQb+64xJ7L7K1JgCVS0hK 00TCdcBhhESk3NASVju+AWBV7q87tI77H+ssa6XcImMX434t9HgfWTCjmqEsm+0Hykbo o1XA== 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=4AkQLLIUIPYpV/JS7s3jTAzAGf+1v6pVPd+k37Rstdw=; b=DkZFb6RnL2Q2FdlTCbnrSKffuJokxLtW6pExL0o0UrvKSmesCLaEjzi5XVeZRaFxJc A7lB3XNxbO6sFIDaIjy/1Ghivs1Dwe2bPwKOt6ixLGF12Uy8G8VXMIo83grwjIW2QW1Q wPjJZGqWHfIBzB/D/0zL4DZyCm3ALiO2kpbqQ//BSs95jCrEnufWpXW1rlkeXUOs3JmE duVYDeblIf26qq6Z+x38h+wUsgDfRO1SGVQxZmmE0FbzJDkYpKanMGGhdeK6EAIca/7N OCPf0okHzJGLjQEfFh4kqFXfUb7aOpVbPV34pHDYFFXlG6nmhVqAkrgva8euTuoZAybg iD5Q== X-Gm-Message-State: APjAAAXMZO6lwZCMeQ6yR9Hoti9PX/choLVOil/F3FY8F7Yv5dOa4nJr BmzBsuCs1oWzMcCoFp+pAIMKzee25pKSnClvL7g= X-Received: by 2002:a67:e9cc:: with SMTP id q12mr4569249vso.208.1554395045066; Thu, 04 Apr 2019 09:24:05 -0700 (PDT) MIME-Version: 1.0 References: <20190402145114.bpt5atxxooufgzz5@flea> In-Reply-To: <20190402145114.bpt5atxxooufgzz5@flea> From: Emil Velikov Date: Thu, 4 Apr 2019 17:24:03 +0100 Message-ID: Subject: Re: [RFC PATCH 01/20] drm: Remove users of drm_format_num_planes To: Maxime Ripard 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 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 Tue, 2 Apr 2019 at 15:51, Maxime Ripard wrote: > > 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? > Hmm I misread the old function as "return info->num_planes ? info->num_planes : 1;" Pardon for the noise. -Emil