Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp564132lqm; Wed, 1 May 2024 08:57:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWcAWb+I2OCTGCchLoA9+xngBifq0xc2zGd9v2cHFRlshTj8652/nKuKGNFIauLk4etMZ0H6BLhnByfa7g6xOpFPf1tJ0DUJgvAJ+o0Dg== X-Google-Smtp-Source: AGHT+IErN3Pwa2XFPbYagoE/uMySE9vWPh9ayG6p5shk83isMWwdWER2eixFzrrVpzBjV84K2RWR X-Received: by 2002:a05:6358:592a:b0:18f:81e1:dc33 with SMTP id g42-20020a056358592a00b0018f81e1dc33mr4257876rwf.2.1714579060498; Wed, 01 May 2024 08:57:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714579060; cv=pass; d=google.com; s=arc-20160816; b=udcyDSI4Ld3YdgZoiNxcz+6IjnKrZIPW+EIFYsGpB0CPUDXWNperWL8TypF9OnPuR7 vLzbFoZYW+wtSKV7uGcXUFTdzWAfTXge2giefOeUPnDja2olDfyGFKVBRuH8y/ut7YO2 i6+FQkNowDPC8xd8/dOLIKs1JC/rZmJdfkLm3tWNT2KiVn5/bcaO/lZgGzEV0S0F1n8p xL5cTMl5S4gQg/jZr+sUcTD2yH2POoZjKGFd/UXlZdn7ov/DkEqx+h2Mpp9d4uLrJEh8 eIsHJ0eGjPOUw/buNr+31Py3Hoa7Lr4bdsXSvWJ2C3YzE56TtFlMabdcfppqQECUbl7Z WGfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Eg8D/K80r70GPeKVeJzvUlTNioKE+UQ27ElJDTct8fc=; fh=R2Rt2YokWKkw8sDKGjS+AtohfoE+7jW0+HM9bKuXdZw=; b=O+cwkOzpEiVBhliEsrE0FHMsuoWbN4uiNx/p94SAXx7sF6dw6BclTaj94NV4/fg/cf P75obt68veZcKwpNXVSwcTFKEOkLj8pF0EvmWyJQhvbEIdLnHr/iXlt9MQlbf+5pGeoY Srm6okTG8A0e5DrxY/T3Q0FSJJ1KwPE2pl0LWecEShTalNFTJ4+Bg3Vkpzc6u5uZt39A AqsyI55kQkSohI/GhJRUS2MxM1bPdvFGPlGttPbDgxM7v6DD5sj8XGDyjq+94PYBp6MU CBw98DsqT44tZuVYb+quu35hrp094LqDF4EqFrph4kodrDeOk0btJDpv4x0GTBvFgS8Z N2+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g8Z2TOtt; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-165522-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165522-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 8-20020a05621420c800b0069b50a68648si21082163qve.423.2024.05.01.08.57.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 08:57:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165522-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=@linaro.org header.s=google header.b=g8Z2TOtt; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-165522-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165522-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 2D6C91C21162 for ; Wed, 1 May 2024 15:57:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EC6D12FB35; Wed, 1 May 2024 15:57:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="g8Z2TOtt" Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA4EA12EBDD for ; Wed, 1 May 2024 15:57:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714579050; cv=none; b=rwAGJSGR95F0HMIGFpAquayAwt8HGpr9jYybE8jBXWMfnZaRNMuVRMg+wrN5u2WmcIUKo2BdZvJs5KpSr0G63CXrqFz31+myyLodjQU4hgUy/oSpIlrDZbe3/yxOzISOhbTtpE0ui6oZjYJ8bHIxBGKWk3vTq51U0lxN+S7rNDA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714579050; c=relaxed/simple; bh=9+wuxJmDrcioFBRkTT68VsS9xa2ednOiLM11tM+SlGs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ieGTRyjLXXi1fZP2poSUEhUeKKIpAtqZbv2B//a7XNl/z/v1ucgCUjFHRLpa73ciNMmqPZzBbPS6/xF5KhIr9kBZF5CMZx1HGEE5W8gSmWOklXvYSRQMG8QW5hqGICu1hazW6nCeeGeXbMKHZB2y7dS1JlVhNwzdJj9oIK3AZ0M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=g8Z2TOtt; arc=none smtp.client-ip=209.85.219.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-de60a51fe21so2708374276.0 for ; Wed, 01 May 2024 08:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714579048; x=1715183848; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Eg8D/K80r70GPeKVeJzvUlTNioKE+UQ27ElJDTct8fc=; b=g8Z2TOtthkAiS3X0ErUqVYPS4xh5jSYO5pBVDyaFnhABYfuY1vFQi8jIncx5dA8s3a ncCbJN3Cey9ViYkYRQAMpcoQpWKdtfQzNaS9cEuKUhZzOXY2TLwYxKAaz+3atK0mkrMe /6LQjnt6G1sryhlp71gahwQG770GerUK7AQD9jCUTD0lkIUq8XJ6bpffkrGfpfQQKzHT hCGcMnoFzmVka3JZUwDFhfX0iU+51lwvb4x/BOOy5028z6zHmXUa2YSptNUw1sitFZAZ 4XeLHAFLSKYdATgRB7pblyMH66IMgcsWBQSTBBBB09K4hC2zgrTlUxrnUrxi8YKz0TnL WYEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714579048; x=1715183848; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Eg8D/K80r70GPeKVeJzvUlTNioKE+UQ27ElJDTct8fc=; b=oqm1P8QrYNy+8VUZOG3XDHZrBGVrn0dXbEEij7PTV3wu0Wx02l+0CRGodQmx7HBonu nVlQ7VnSmZGYhKUV0mPEuarW1CWE9o2PqYBCh79IdrZnqJlf4qvezpIhSaNW5F2xqpxD HNt31737/SolHbr4ADYsVO9j4GmLddqNKeUgEkCFKTwVFNfMo6TOXlgecSNv7pljxurc JaEKXiN7p06A74A+M0OMycoAOSQvRsprMKdYp5nQ74Jn58WnQRzmg2YYo0OZn1uXUich Y2TWWCd5cvwSQTQsfUN4xx3WgzHx4FgevtKH8FuYwA87k+9b9pO2RQjz5RREwfmhavaj VwAw== X-Forwarded-Encrypted: i=1; AJvYcCXlPy6QAP2CNhEzn6eWz5TqiOm9oVbSoPMhHxk/3hkeR96AJvKSP7gWk4HJZsE6h5hFrtupN8YnHfdssXd8ewMZ+jGXqRs5IMAnsHb8 X-Gm-Message-State: AOJu0YxcRWH2/p0I6SJ5u9jnDxwaf4hOpkI8LMITxPY0HowCIzW8kmhn IZj+TtkFZogNkz2Syo2ryOMg9uNrH474pdjwafwZlYqgjeiw/Zn81SJy9/irSiN6zLiYVQDfTHB eRs3h7QNE8JLCjqYbH4TY/2trLQcDJ2wJM+xP4g== X-Received: by 2002:a25:a2c6:0:b0:de4:6334:5534 with SMTP id c6-20020a25a2c6000000b00de463345534mr3234633ybn.63.1714579047482; Wed, 01 May 2024 08:57:27 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240426235857.3870424-1-dianders@chromium.org> <20240426165839.v2.4.Ie94246c30fe95101e0e26dd5f96e976dbeb8f242@changeid> <2af446d3-7834-4a6b-897b-b14c6bccff65@linaro.org> <87y18w2n6h.fsf@intel.com> In-Reply-To: From: Dmitry Baryshkov Date: Wed, 1 May 2024 18:57:16 +0300 Message-ID: Subject: Re: [PATCH v2 4/8] drm/mipi-dsi: Introduce mipi_dsi_*_write_seq_multi() To: Doug Anderson Cc: Jani Nikula , neil.armstrong@linaro.org, dri-devel@lists.freedesktop.org, Linus Walleij , lvzhaoxiong@huaqin.corp-partner.google.com, Hsin-Yi Wang , Javier Martinez Canillas , Joel Selvaraj , Cong Yang , Sam Ravnborg , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 1 May 2024 at 18:49, Doug Anderson wrote: > > Hi, > > On Mon, Apr 29, 2024 at 8:39=E2=80=AFAM Jani Nikula wrote: > > > > 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 multipl= e calls. 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 function > > >> > + * many times in a row and just checking the error at the end t= o see 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= while we could pass > > >> a single int over without encapsulating it with mipi_dsi_multi_conte= xt. > > >> > > >> 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, in= t *accum_err, > > >> const void *data, size_t len); > > >> > > >> is the same, and it avoids having to declare a mipi_dsi_multi_contex= t and set ctx->dsi, > > >> and I'll find it much easier to migrate, just add a &ret and make su= re ret 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 whe= n > > > 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 instea= d > > > 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 looke= d > > > 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 an= d > > > 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. > > I've gone ahead and sent out a v3 where I still leave it as taking > `struct mipi_dsi_multi_context`. Neil: if you feel strongly about it, > I have no problem sending out a v4. I still think that the size > savings of using the context are a good "tiebreaking" factor in > choosing between the two styles... ;-) I like the idea of context. If later on we need to add additional data (like DSC PPS or drm_mode), we can simply extend the context structure. > > -Doug --=20 With best wishes Dmitry