Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp739195lqd; Wed, 24 Apr 2024 15:54:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXiMobD40N6xC9j/tnth98nWKw3CARo46Zs9iZ7ALaLZyWcGcuOsIk3yMc8/GTBy64M35gA0TPxYLbgvB3wyut2VX7Lix2XdNDdkFhqRA== X-Google-Smtp-Source: AGHT+IGDd4x0lrY/Z3QBfVZ5M0Ho4pGIyiJ3BVybePblysYGhmgKoxgpl/7SILE8nZTSGn44dBUT X-Received: by 2002:a17:902:f547:b0:1e5:62:7ac0 with SMTP id h7-20020a170902f54700b001e500627ac0mr5550305plf.14.1713999239926; Wed, 24 Apr 2024 15:53:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713999239; cv=pass; d=google.com; s=arc-20160816; b=vs3etGX1kh6y/9oOt9V+LoVKa6h3yjLWg+vCbrUUJ/KsJaQboCFaRlGNIQsHoaOx8R O7eGxXhQ4LydFElJyeWT4l/rpgTT03cEd8zULmxEQc3VTGVnsnGl6WKR0LPU5LjK1LoY PG8bOYEs7qHb+J68UuaFtLgr9Vy2U6J7sBuZdeVTR0UkrG267em4eEFUpn9HjCpLQLHC CzGrZSlFSf5d90hiKtgcIP8qfpv4K9bHs68Ww3sflAFOUG1CvBmPVN0Z8G2D3SDCI1N3 gzqWlNEYPEMXEUo025/WfHYhHy9mV+VK0CJdQ9RBFqFNUUvZqin20sF10qPwCJj8MRiO D4qw== 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=GLM/Gzp3LttpkW6eOimYma73Nk3MMLdnbj7i6AMnYdM=; fh=DLY+7U/G1LMllFy7FBAjPGDYx81i5p+R7D1yM/gsMBA=; b=TSUUFMHEh3+o/Fttm0bGzMdTXcu0BUpPmi3rPYahN0k1sq4GbzVY6Mpgb4MKhZinb+ vB2qbVIC94oTLLdHjq2RD0eTUJ3nXtaS36Jdeh+QuWE6j9BghF238FkfrdFFHWN0Lnf7 +SQIgCyspjcoqNJuND8dP8kPz2Ch0WSpdNEUMl0iD0DwwHekEpAC2w6crEc0bDft+vxI 1LF1JpxjZrTVvHEsvAK5jrcY7q5GDUVLhaSVHOECGo0CoMe6HV4v9UaJVAL64tSIfHC0 f2pDxHFvafGekj/0YrWdFs0fObCw0phWXUztSw/CH8iAv8utKaRdRmcHzVenfw+CYF9K xYbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lm1/qTA/"; 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-157805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157805-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l16-20020a170903121000b001e9c3c69866si5745634plh.336.2024.04.24.15.53.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:53:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lm1/qTA/"; 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-157805-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157805-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 51471B24631 for ; Wed, 24 Apr 2024 22:51:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2994A16E89C; Wed, 24 Apr 2024 22:51:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lm1/qTA/" Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (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 CBF96155A50 for ; Wed, 24 Apr 2024 22:51:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713999067; cv=none; b=uhRSx5mmcE5qemF7OLcM66r+qAUxiD/LZX/c5fpanyXi6XH+kInuLofljTA6svaO1sb4FxZntDB0mrQ2Ya0O0t9PbciAzzSWxEyVotBhlaD6Wmkk/x5tu9V+b+bIR0K1nn+s4XyBDsas1T7qfNjULjgwDS3KJ8qir3LQlwIrBIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713999067; c=relaxed/simple; bh=qqd1zB8UQojIx8Ao/aNnMFZ4CF7YZC9OadhVYG1ei70=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=TyN4lUNWD8Zh9CH+/7ZXWod+XhX0Y2TKQrzP3pczg+Su1jPGIrswosXccOiaAS0eseKR5YUsuajhmJkwqs6lxamf6dcX192kiapoR0PA4Bofzc9q2pOulY+e7Z1GjqSTC6tCHiqXjD72f5HqF3YsmLukPRaoP43kG136fM4hPYw= 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=lm1/qTA/; arc=none smtp.client-ip=209.85.219.176 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-f176.google.com with SMTP id 3f1490d57ef6-de462979e00so420385276.3 for ; Wed, 24 Apr 2024 15:51:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713999064; x=1714603864; 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=GLM/Gzp3LttpkW6eOimYma73Nk3MMLdnbj7i6AMnYdM=; b=lm1/qTA/DwZLtWXT3iIXpHzGEEiqymd1ZdxZKdbFC/f5gEFXwizWcHe7gna4XOQNbl +stTU1oQWe9x1KH5ic6nk4cWETQQF2d03UO+hzyLazrCAgppk232Y+UqQ8VXsUK3bNP6 eV5niTICj68VDkSEZOUOFJVLf7J0zy/qum5ONEs4YEiOZiZ+S8UQzraR4DKce6JD6moS m0IavXiWfPLKvTpoOVoo1c7c0dpxPsRgoXkyGXosBP0GtSJQCAVL+2Dzv7LmM0b2fR8i VOKQDZrv/FaKJnzSN5aNIVT5EEyaQ5UnxbPHh4gvjJOvMKG89mAbE8dMCEX2997HB+na dt3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713999064; x=1714603864; 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=GLM/Gzp3LttpkW6eOimYma73Nk3MMLdnbj7i6AMnYdM=; b=HZveg2vUB2gItj+E5KBZMdtO6LntDJMBnpLVr0Nqpbdr46JyMfG2s12fuZL/k4tWv9 8ULssFxXVQP5ojW2WizD/JSF+mHSMLJ6O9u0z0jbAO6jLqfmFtP86wHxA1idKlmbs1aT uEwwSqyw1ZNq/zJytOSeL0KWSBR69sEoo2D7o0TeEnEDjMoyx11cTpRfA+f1VKZg3Fp8 tmpQDOgLHEOzTT3S9ebzP8j3euO/Deyi2+BT+EyjT69Cbc7qlA66+uaIviBMa96WB78Y mOlxZPoI9bSJpQ/bMtDl+d2LRRaG39OxF9lN8suGSw+S26xV2E5Hs9n9tTJauc/fI+EA rNKQ== X-Forwarded-Encrypted: i=1; AJvYcCUsSlVEm49XwdlTxOuKfWoWePUdHcPOGA8VP9sY8BLulbctyC4VpFzPD8rQtt/71vH4XtOyO7/uxeElcJUrPqCmWaOoTx7J1nKlU/fG X-Gm-Message-State: AOJu0Yx62TYDAkRUX/jy5Y1HlPjyTuoYqqjLfxlBjP0MbkERCr13mINW GkQwB8VAJnSLe+hMfI7tPwd9ctrGAuqTb8P0a1isvW7cRFS2Jd4sGZGAb/LaGOCPVfabfw9+zab xhtZ9NR9oLt+rHJQv+oABHu2ultexdLTJmYrYSlek2G1LJlwZ X-Received: by 2002:a25:a509:0:b0:dca:59a7:896b with SMTP id h9-20020a25a509000000b00dca59a7896bmr4173378ybi.50.1713999063835; Wed, 24 Apr 2024 15:51:03 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240418081548.12160-1-lvzhaoxiong@huaqin.corp-partner.google.com> <20240418081548.12160-3-lvzhaoxiong@huaqin.corp-partner.google.com> In-Reply-To: From: Dmitry Baryshkov Date: Thu, 25 Apr 2024 01:50:52 +0300 Message-ID: Subject: Re: [PATCH v1 2/2] drm/panel: kd101ne3: add new panel driver To: Hsin-Yi Wang Cc: Doug Anderson , lvzhaoxiong , mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, cong yang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 25 Apr 2024 at 01:15, Hsin-Yi Wang wrote: > > On Wed, Apr 24, 2024 at 2:49=E2=80=AFPM Dmitry Baryshkov > wrote: > > > > On Thu, 25 Apr 2024 at 00:04, Doug Anderson wrote= : > > > > > > Hi, > > > > > > On Tue, Apr 23, 2024 at 2:20=E2=80=AFPM Dmitry Baryshkov > > > wrote: > > > > > > > > On Tue, Apr 23, 2024 at 01:41:59PM -0700, Doug Anderson wrote: > > > > > Hi, > > > > > > > > > > On Tue, Apr 23, 2024 at 11:10=E2=80=AFAM Hsin-Yi Wang wrote: > > > > > > > > > > > > > > > > +#define _INIT_DCS_CMD(...) { \ > > > > > > > > > > + .type =3D INIT_DCS_CMD, \ > > > > > > > > > > + .len =3D sizeof((char[]){__VA_ARGS__}), \ > > > > > > > > > > + .data =3D (char[]){__VA_ARGS__} } > > > > > > > > > > + > > > > > > > > > > +#define _INIT_DELAY_CMD(...) { \ > > > > > > > > > > + .type =3D DELAY_CMD,\ > > > > > > > > > > + .len =3D sizeof((char[]){__VA_ARGS__}), \ > > > > > > > > > > + .data =3D (char[]){__VA_ARGS__} } > > > > > > > > > > > > > > > > > > This is the third panel driver using the same appoach. Ca= n you use > > > > > > > > > mipi_dsi_generic_write_seq() instead of the huge table? O= r if you prefer > > > > > > > > > the table, we should extract this framework to a common h= elper. > > > > > > > > > (my preference is shifted towards mipi_dsi_generic_write_= seq()). > > > > > > > > > > > > > > > > > The drawback of mipi_dsi_generic_write_seq() is that it can= cause the > > > > > > > > kernel size grows a lot since every sequence will be expand= ed. > > > > > > > > > > > > > > > > Similar discussion in here: > > > > > > > > https://lore.kernel.org/dri-devel/CAD=3DFV=3DWju3WS45=3DEpX= MUg7FjYDh3-=3Dmvm_jS7TF1tsaAzbb4Uw@mail.gmail.com/ > > > > > > > > > > > > > > > > This patch would increase the module size from 157K to 572K= . > > > > > > > > scripts/bloat-o-meter shows chg +235.95%. > > > > > > > > > > > > > > > > So maybe the common helper is better regarding the kernel m= odule size? > > > > > > > > > > > > > > Yes, let's get a framework done in a useful way. > > > > > > > I'd say, drop the _INIT_DELAY_CMD. msleep() and usleep_range(= ) should be > > > > > > > used instead (and it's up to the developer to select correct = delay > > > > > > > function). > > > > > > > > > > > > > > > > > > > > > > > > > + > > > > > > > > > > +static const struct panel_init_cmd kingdisplay_kd101ne= 3_init_cmd[] =3D { > > > > > > > > > > + _INIT_DELAY_CMD(50), > > > > > > > > > > + _INIT_DCS_CMD(0xE0, 0x00), > > > > > > > > > > > > > > [skipped the body of the table] > > > > > > > > > > > > > > > > > + _INIT_DCS_CMD(0x0E, 0x48), > > > > > > > > > > + > > > > > > > > > > + _INIT_DCS_CMD(0xE0, 0x00), > > > > > > > > > > > > > > > > > + _INIT_DCS_CMD(0X11), > > > > > > > > > > > > > > Also, at least this is mipi_dsi_dcs_exit_sleep_mode(). > > > > > > > > > > > > > > > > > + /* T6: 120ms */ > > > > > > > > > > + _INIT_DELAY_CMD(120), > > > > > > > > > > + _INIT_DCS_CMD(0X29), > > > > > > > > > > > > > > And this is mipi_dsi_dcs_set_display_on(). > > > > > > > > > > > > > > Having a single table enourages people to put known commands = into the > > > > > > > table, the practice that must be frowned upon and forbidden. > > > > > > > > > > > > > > We have functions for some of the standard DCS commands. So, = maybe > > > > > > > instead of adding a single-table based approach we can improv= e > > > > > > > mipi_dsi_generic_write_seq() to reduce the bloat. E.g. by mov= ing the > > > > > > > error handling to a common part of enable() / prepare() funct= ion. > > > > > > > > > > > > > > > > > > > For this panel, I think it can also refer to how > > > > > > panel-kingdisplay-kd097d04.c does. Create the table for init cm= d data, > > > > > > not what operation to use, and use mipi_dsi_generic_write_seq()= when > > > > > > looping through the table. > > > > > > > > > > Even more similar discussion: > > > > > > > > > > https://lore.kernel.org/r/CAD=3DFV=3DUGDbNvAMjzWSOvxybGikQcvW9JsR= tbxHVg8_97YPEQCA@mail.gmail.com > > > > > > > > It seems I skipped that thread. > > > > > > > > I'd still suggest a code-based solution compared to table-based one= , for > > > > the reasons I've outlined before. Having a tables puts a pressure o= n the > > > > developer to put commands there for which we already have a > > > > command-specific function. > > > > > > The problem is that with these panels that need big init sequences th= e > > > code based solution is _a lot_ bigger. If it were a few bytes or a > > > 1-2KB then fine, but when Hsin-Yi measured Linus W's attempt to move > > > from a table to code it was 100K difference in code [1]. I would also > > > say that having these long init sequences done as separate commands > > > encourages people to skip checking the return values of each of the > > > transfer functions and I don't love that idea. > > > > > > It would be ideal if these panels didn't need these long init > > > sequences, but I don't have any inside knowledge here saying that the= y > > > could be removed. So assume we can't get rid of the init sequences it > > > feels like we have to find some way to make the tables work for at > > > least the large chunks of init code and encourage people to make the > > > tables readable... > > > > > > I did a quick check on the boe-tv101wum-nl6 driver by converting the > > writes to use the following macro: > > > > #define mipi_dsi_dcs_write_cmd_seq(dsi, cmd, seq...) > > \ > > do { = \ > > static const u8 d[] =3D { cmd, seq }; = \ > > ret =3D mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)= ); \ > > if (ret < 0) = \ > > goto err; = \ > > } while (0) > > > > And then at the end of the init funciton having > > > > err: > > dev_err(panel->dev, > > "failed to write command %d\n", ret); > > return ret; > > } > > > > I'm not sure about the coding style rule here, would it be considered > unclear that caller of mipi_dsi_dcs_write_cmd_seq() needs to have err > block, but the block may not be directly used in that caller and is > only jumped from the macro? I'm also not sure here. It was a quick and dirty test. We might as well do something like ret =3D mipi_dsi_dcs_write_cmd_seq(dsi, ...); if (ret) goto err; all over the place. > > > > Size comparison: > > text data bss dec hex filename > > before > > 34109 10410 18 44537 adf9 > > ../build-64/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.o > > making init data const > > 44359 184 0 44543 adff > > ../build-64/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.o > > with new macros > > 44353 184 0 44537 adf9 > > ../build-64/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.o > > > > As you can see, there is literally no size difference with this macro i= n place. > > The only drawback is that the init stops on the first write rather > > than going through the sequence. > > > > WDYT? I can turn this into a proper patch if you think this makes sense= . > > > > > > > > > > > [1] https://lore.kernel.org/r/CAD=3DFV=3DUFa_AoJQvUT3BTiRs19WCA2xLVeQ= OU=3D+nYu_HaE0_c6Q@mail.gmail.com > > > > > > > > -- > > With best wishes > > Dmitry -- With best wishes Dmitry