Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1446166lqa; Mon, 29 Apr 2024 08:39:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+vevIQ6+r+m5q/c9yFmJQIkNTKtFetFbjVn/zb9wUacudvbI4cVKh8zZF3MNfx3AAQEwLZe8nSiUptNrSIByZlHUeMzjmzw2hMipb2g== X-Google-Smtp-Source: AGHT+IFpuBy5niEgzBnYKfXE0bJeG5Bwj2mpnEdnq/SwXcRRHNyJFrj5vn3OQS3JqhkwgAWHj2j2 X-Received: by 2002:a0c:fa04:0:b0:69b:60b6:7c5d with SMTP id q4-20020a0cfa04000000b0069b60b67c5dmr13906qvn.18.1714405177120; Mon, 29 Apr 2024 08:39:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714405177; cv=pass; d=google.com; s=arc-20160816; b=xQUKlyjNbzRbl+149jD9c9DJDcWXSgJ23disa4lrjHj4645r+KXJkkyfyoHfrXA7nO P0daVt2iQ51fwap54YMALebFeCsRkoSP5zMG+4IEMWGO/8cSdEw1wJEB7Ty7cU3mzgZq UtJgdQfNyQCRcQiAnC7SFUyfxbh7OBlzaZERcN/U8M1gKP/5t2nt/owqjPFNspE+yo97 NHAG79rRDIujNKYxgYc27J49TWVjfylODLLxe5hcXrVe+Y4RT07dii3QSRSGIDSVR5YZ lYuHW2ZqACQGbeuxuG3AqK17EyGxBhHmTK14d3Upfm45viPcApfbsbGDyRKPRn2+cCgD HXZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=xu/b/Gxn7KOvcE24hgrSc5P1T4ojN3OXHCR8QSbx/uY=; fh=0HFHMstywjlksu6R7p61APXp0WY7YWedTQT+bGIqF7w=; b=RR27aPHuSCC1CCA8BQKInHfBTWnDd8/LY9tg5VrSS+XufsKts321eqF+baxRlIrgAw 2GPfsoxaLCfuCqTNIbOD7kHElSbb0BdqE6U6Q01eGfIuNPhJlWWo6sn1OoyryWCKYCwl zeclSUzl/nDBNi0u+svlWQqxne+jR+kPwnnSJ4ZcF+rsOrx/IcObJJ2GgqiNgt7hWyZn Op3uGTw2iU9GEn190QtSyTQQ0iADP0y5FPpq2sZV/JYa4RQ/97hLdtWjZDLNYWtF50FW PyTHAPll0x7kdulnSxbYZA+1EFH7zuoy31WmYfqA6kMWaiA9oDQxJPMvKUwSe2vvyL9N okrw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H4kUOyiU; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-162602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q3-20020ad45743000000b006a0c8fa5d2asi3683957qvx.307.2024.04.29.08.39.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:39:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H4kUOyiU; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-162602-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162602-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B0E851C217E1 for ; Mon, 29 Apr 2024 15:39:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B97B8249F; Mon, 29 Apr 2024 15:39:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="H4kUOyiU" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8A3C7E0F6 for ; Mon, 29 Apr 2024 15:39:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714405169; cv=none; b=DOhbJ2MfBqaGHemIKkVaeDiNG5LXx0El16CAk8e2sJNt9fuIZk5Mb+qJnUhDyfLvkuZXfdndqqgc2pUr0DJ6oco30+By7xIK51/Q39WJH06CqOhfV73bmEmc77CV4Wku8Xk2OVvnopPh53Ez4oNYuurTkvpbcmcljWrQYZUh4nQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714405169; c=relaxed/simple; bh=h9MGGwKZVRUgN0bDFdFcodYM4/Bv2gUDW4BQmK4V7rk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=L0bnWOhMo/Q0ZGd37YX8V/64uGXk4nWcE4dGA5Auh6DfgMGlr5pdJtPGU1W2I8U30DrHDECbVMOIug+WMgVdqC5uer7jwQAfS/3w/fFrOFyhLM7Wj7zbc1SiwlUNuxkDu/E9v434OWlt2pLQkPDTWsN9+XYPPOlfiea/gie+hgI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=H4kUOyiU; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714405168; x=1745941168; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=h9MGGwKZVRUgN0bDFdFcodYM4/Bv2gUDW4BQmK4V7rk=; b=H4kUOyiUqX0GynofenalJU333BmU9+MREeMZ+t6deRiptsHgthOrtvso jcSZ4ZJE4/ZmB5fsL4jzFKDUwXq+/6ol3EroYgoiVWibw7gvZHcUoPGjq Dzi8aqGk5u5xHwDRcgRg+kmJlNWU6BqN52HbMYPJLF56iuWCHnSBfAtnL JX64CowOucAcSC6BL3W+mM845oKQqHKw+p1yw+8JMXrxTFUu/ovKzts5M XMK0C6nYD1qiS1P/yQPRu3glLAZXaXOrptO8j4+kxKhkqm0/iqT/QavXC qCXl4K+WBoEluQu+9CveliHA5Wg85xSNMAIvxwUDeEHEL5WNRPo2QQDdC w==; X-CSE-ConnectionGUID: 3Phjp3EKRraEdD1kg0FkWw== X-CSE-MsgGUID: /OwDMXopQTizp0He0u8Raw== X-IronPort-AV: E=McAfee;i="6600,9927,11059"; a="35464161" X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="35464161" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 08:39:27 -0700 X-CSE-ConnectionGUID: 3jPk27OrSBajaLlKSBR73g== X-CSE-MsgGUID: 4IAmxJ5xSk6hssnGCt8dsg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,239,1708416000"; d="scan'208";a="26762827" Received: from aantonov-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.49.167]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2024 08:39:21 -0700 From: Jani Nikula To: Doug Anderson , neil.armstrong@linaro.org Cc: dri-devel@lists.freedesktop.org, Linus Walleij , lvzhaoxiong@huaqin.corp-partner.google.com, Hsin-Yi Wang , Javier Martinez Canillas , Joel Selvaraj , Dmitry Baryshkov , Cong Yang , Sam Ravnborg , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 4/8] drm/mipi-dsi: Introduce mipi_dsi_*_write_seq_multi() In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20240426235857.3870424-1-dianders@chromium.org> <20240426165839.v2.4.Ie94246c30fe95101e0e26dd5f96e976dbeb8f242@changeid> <2af446d3-7834-4a6b-897b-b14c6bccff65@linaro.org> Date: Mon, 29 Apr 2024 18:39:18 +0300 Message-ID: <87y18w2n6h.fsf@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, 29 Apr 2024, Doug Anderson wrote: > Hi, > > On Mon, Apr 29, 2024 at 2:38=E2=80=AFAM Neil Armstrong > wrote: >> >> > +/** >> > + * struct mipi_dsi_multi_context - Context to call multiple MIPI DSI = funcs in a row >> > + * @dsi: Pointer to the MIPI DSI device >> > + * @accum_err: Storage for the accumulated error over the multiple ca= lls. Init >> > + * to 0. If a function encounters an error then the error code will= be >> > + * stored here. If you call a function and this points to a non-zero >> > + * value then the function will be a noop. This allows calling a fu= nction >> > + * many times in a row and just checking the error at the end to se= e if >> > + * any of them failed. >> > + */ >> > + >> > +struct mipi_dsi_multi_context { >> > + struct mipi_dsi_device *dsi; >> > + int accum_err; >> > +}; >> >> I like the design, but having a context struct seems over-engineered whi= le we could pass >> a single int over without encapsulating it with mipi_dsi_multi_context. >> >> void mipi_dsi_dcs_write_buffer_multi(struct mipi_dsi_multi_context *ctx, >> const void *data, size_t len); >> vs >> void mipi_dsi_dcs_write_buffer_multi(struct mipi_dsi_device *dsi, int *a= ccum_err, >> const void *data, size_t len); >> >> is the same, and it avoids having to declare a mipi_dsi_multi_context an= d set ctx->dsi, >> and I'll find it much easier to migrate, just add a &ret and make sure r= et is initialized to 0. > > Yeah, I had the same reaction when Jani suggested the context style > [1] and I actually coded it up exactly as you suggest above. I then > changed my mind and went with the context. My motivation was that when > I tested it I found that using the context produced smaller code. > Specifically, from the description of this patch we see we end up > with: > > Total: Before=3D10651, After=3D9663, chg -9.28% > > ...when I didn't have the context and I had the accum_err then instead > of getting ~9% smaller I believe it actually got ~0.5% bigger. This > makes some sense as the caller has to pass 4 parameters to each call > instead of 3. > > It's not a giant size difference but it was at least some motivation > that helped push me in this direction. I'd also say that when I looked > at the code in the end the style grew on me. It's really not too > terrible to have one line in your functions that looks like: > > struct mipi_dsi_multi_context ctx =3D { .dsi =3D boe->dsi }; > > ...and if that becomes the canonical way to do it then it's really > hard to accidentally forget to initialize the error value. With the > other API it's _very_ easy to forget to initialize the error value and > the compiler won't yell at you. It also makes it very obvious to the > caller that this function is doing something a little different than > most Linux APIs with that error return. > > So I guess I'd say that I ended up being pretty happy with the > "context" even if it does feel a little over engineered and I'd argue > to keep it that way. That being said, if you feel strongly about it > then we can perhaps get others to chime in to see which style they > prefer? Let me know what you think. > > > [1] https://lore.kernel.org/r/8734r85tcf.fsf@intel.com FWIW, I don't feel strongly about this, and I could be persuaded either way, but I've got this gut feeling that an extensible context parameter might be benefitial future proofing in this case. BR, Jani. --=20 Jani Nikula, Intel