Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp16824526rwd; Mon, 26 Jun 2023 16:03:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51h9IZUlXFmJrZ5iwQED2J8KOMxHeQTq0AWyNFx9gzSOlvQq04a7EDEoZ/ZAtbaMKDT5bT X-Received: by 2002:a2e:97d3:0:b0:2b6:26e4:8c1c with SMTP id m19-20020a2e97d3000000b002b626e48c1cmr4030848ljj.49.1687820582544; Mon, 26 Jun 2023 16:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687820582; cv=none; d=google.com; s=arc-20160816; b=Hkek5kz5K1NvICaChWo+yivztNh7uOgr5faFGyioCJBcKrdyM2qstkS13pKvPBm9nc AYlStxp78bsemSc2kqp0pTm3n3cuRUtljwnFQR4oO/HNJpskzH93zhty3/IqYWH7K6ba qS0zwp0lMtWIQyE8BLbD+CbhucOwUSLge6BEDUy80g4BXZKp2w3ENtFAmNii7ZlqRUQD nmDgTqAESW/fPUWFizxvE8Wy46+IH62LCoAZ4YiAq4co/cAA2odT5N8gr1Al/t64H6+7 fXNiEIDrOu25mKdQY/+wJjC7fP2GT0zLvKLs4hCmsII5hP4ZUbLdQPCViohs+5E+I6de dAog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6dAnLf/XZMv1d7lTmYjxhUjdD/xdtixhtUmJbq4ft4k=; fh=yf5uoHzLnT+eqfTvRx8zYW5oo4s3oq39bepUnpHKloQ=; b=W9Nk6cFQ/90glkNyJ6//IuF2ikQqecB/EnBw2Dg5EbqBJVu+4hF+uXh7ZcxvlYS81y hwyG68oSB1ubFpaLH/OHePEEee45tu8wPKXmKC2E9Bnj9BLSb+Ki3YDwHLlAvC6MpCJa AibGJoHYeXUmBdVWkxxLI89jOZvW2h9u9etT5o2JDmoG2BIrnnsKTrk71u0VtHwZqzuT ah4ALVrB10nsJZHfMdixJ09aTxhn4qYUeSZ7xXqH1DSQJ8ldnJcVJ5NG+2aTJCtsuIit c2yb2aIcSt4QyZoe0M4hKksVbZTjjH9NcCFffLEy8ajVWv8m2X5W4bBRRxD/5vTSWjHr Ed7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="gHvQ3//8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x1-20020aa7dac1000000b0051bdd99a9d5si2958467eds.423.2023.06.26.16.02.37; Mon, 26 Jun 2023 16:03:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="gHvQ3//8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229737AbjFZWty (ORCPT + 99 others); Mon, 26 Jun 2023 18:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbjFZWtx (ORCPT ); Mon, 26 Jun 2023 18:49:53 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AB78CF for ; Mon, 26 Jun 2023 15:49:52 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-98e011f45ffso241760666b.3 for ; Mon, 26 Jun 2023 15:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1687819788; x=1690411788; 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=6dAnLf/XZMv1d7lTmYjxhUjdD/xdtixhtUmJbq4ft4k=; b=gHvQ3//8UA2P9RVDmesYBeFBimg9OkR62tmPy4SYEtKHkq+K+Hq8IHGWm6Uejnzydf WybcsHl40wkP4rDSpaarqM4inn5qQeN3QSqLJ1RzmEvR3/SxU2l+G9nj2zIcm+QyZexB AOfzcdbRZk3U8dNNzTqWrA+/7NR2ynIThovi8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687819788; x=1690411788; 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=6dAnLf/XZMv1d7lTmYjxhUjdD/xdtixhtUmJbq4ft4k=; b=EILLHNjSf3CpUP+y66buYU779r5Um+O040rWcGRw3Xr/QALbPZIfx75GOTgWP6j7gy ph/u12na0T9sgYWeNiuZNJ9lcJ0U/OBYm5ryJ1O3rJuwwQt3wpCganpA7U0I+QRWlGrk pS3WOcOYKlA0IiM81asxq9xggIgrn6Malx1Hh1iGztwdlhxt2ZwpIEezqiRJ0Xu5xkAc h3dF5ncr0yPKkl+Q5/INqY2+ByNaliIcogen44vVpgvkWWPOUwRfkKO0ZxPCauowAQI0 9n4edel9GKHkDjzg1HFrfNbKKY32/MTYJaBm2Zcl/rYjIjpfE7PQxDBaiavrPqbg3TXV tKnw== X-Gm-Message-State: AC+VfDxPsvjb7ojEYGNfcMWgfq/Ox3edyFcEXojhDuqrH5UDLW+r4vmb 0NmuexkE+FgUG0QSJHw5cB6pxSX/vK2VeK7abfGup4kS X-Received: by 2002:a17:907:3f18:b0:983:cb6c:8aa3 with SMTP id hq24-20020a1709073f1800b00983cb6c8aa3mr23634499ejc.59.1687819788664; Mon, 26 Jun 2023 15:49:48 -0700 (PDT) Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com. [209.85.208.45]) by smtp.gmail.com with ESMTPSA id k19-20020a1709061c1300b0098dd3981be9sm3756624ejg.224.2023.06.26.15.49.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Jun 2023 15:49:47 -0700 (PDT) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-514ad92d1e3so1779a12.1 for ; Mon, 26 Jun 2023 15:49:47 -0700 (PDT) X-Received: by 2002:a50:9fa4:0:b0:51a:1f15:9ddc with SMTP id c33-20020a509fa4000000b0051a1f159ddcmr207492edf.6.1687819787201; Mon, 26 Jun 2023 15:49:47 -0700 (PDT) MIME-Version: 1.0 References: <20230607215224.2067679-1-dianders@chromium.org> <20230607144931.v2.8.Ib1a98309c455cd7e26b931c69993d4fba33bbe15@changeid> In-Reply-To: From: Doug Anderson Date: Mon, 26 Jun 2023 15:49:34 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 08/10] HID: i2c-hid: Support being a panel follower To: Benjamin Tissoires Cc: Jiri Kosina , Bjorn Andersson , Konrad Dybcio , Rob Herring , Frank Rowand , Krzysztof Kozlowski , Conor Dooley , Neil Armstrong , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org, Dmitry Torokhov , linux-input@vger.kernel.org, Daniel Vetter , linux-kernel@vger.kernel.org, hsinyi@google.com, cros-qcom-dts-watchers@chromium.org, devicetree@vger.kernel.org, yangcong5@huaqin.corp-partner.google.com, linux-arm-msm@vger.kernel.org, Chris Morgan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Benjamin, On Thu, Jun 8, 2023 at 8:37=E2=80=AFAM Benjamin Tissoires wrote: > > > +static const struct drm_panel_follower_funcs i2c_hid_core_panel_follow= er_funcs =3D { > > + .panel_prepared =3D i2c_hid_core_panel_prepared, > > + .panel_unpreparing =3D i2c_hid_core_panel_unpreparing, > > +}; > > Can we make that above block at least behind a Kconfig? > > i2c-hid is often used for touchpads, and the notion of drm panel has > nothing to do with them. So I'd be more confident if we could disable > that code if not required. Now that other concerns are addressed, I started trying to write up a v3 and I found myself writing this as the description of the Kconfig entry: -- config I2C_HID_SUPPORT_PANEL_FOLLOWER bool "Support i2c-hid devices that must be power sequenced with a panel" Say Y here if you want support for i2c-hid devices that need to coordinate power sequencing with a panel. This is typically important when you have a panel and a touchscreen that share power rails or reset GPIOs. If you say N here then the kernel will not try to honor any shared power sequencing for your hardware. In the best case, ignoring power sequencing when it's needed will draw extra power. In the worst case this will prevent your hardware from functioning or could even damage your hardware. If unsure, say Y. -- I can certainly go that way, but I just wanted to truly make sure that's what we want. Specifically: 1. If we put the panel follower code behind a Kconfig then we actually have no idea if a touchscreen was intended to be a panel follower. Specifically the panel follower API is the one that detects the connection between the panel and the i2c-hid device, so without being able to call the panel follower API we have no idea that an i2c-hid device was supposed to be a panel follower. 2. It is conceivable that power sequencing a device incorrectly could truly cause hardware damage. Together, those points mean that if you turn off the Kconfig entry and then try to boot on a device that needed that Kconfig setting that you might damage hardware. I can code it up that way if you want, but it worries me... Alternatives that I can think of: a) I could change the panel follower API so that panel followers are in charge of detecting the panel that they follow. Today, that looks like: panel_np =3D of_parse_phandle(dev->of_node, "panel", 0); if (panel_np) /* It's a panel follower */ of_node_put(panel_np); ...so we could put that code in each touchscreen driver and then fail to probe i2c-hid if we detect that we're supposed to be a panel follower but the Kconfig is turned off. The above doesn't seem massively ideal since it duplicates code. Also, one reason why I put that code in drm_panel_add_follower() is that I think this concept will eventually be needed even for non-DT cases. I don't know how to write the non-DT code right now, though... b) I could open-code detect the panel follower case but leave the actual linking to the panel follower API. AKA add to i2c-hid: if (of_property_read_bool(dev->of_node, "panel")) /* It's a panel follower */ ...that's a smaller bit of code, but feels like an abstraction violation. It also would need to be updated if/when we added support for non-DT panel followers. c) I could add a "static inline" implementation of b) to "drm_panel.h". That sounds great and I started doing it. ...but then realized that it means adding to drm_panel.h: #include #include ...because otherwise of_property_read_bool() isn't defined and "struct device" can't be dereferenced. That might be OK, but it looks as if folks have been working hard to avoid things like this in header files. Presumably it would get uglier if/when we added the non-DT case, as well. That being said, I can give it a shot... -- At this point, I'm hoping for some advice. How important is it for you to have a Kconfig for "I2C_HID_SUPPORT_PANEL_FOLLOWER"? NOTE: even if I don't add the Kconfig, I could at least create a function for registering the panel follower that would get most of the panel follower logic out of the probe function. Would that be enough? Thanks! -Doug