Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2923325rdb; Fri, 22 Sep 2023 12:08:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELB/GRON4TyDl1nVlYWa0AZ2uz4JzP50ya7e9+IgAwzyYyldW6BFdUQVRjsc4mMGoWpxXy X-Received: by 2002:a05:6a00:1a8d:b0:68e:3fe6:2c82 with SMTP id e13-20020a056a001a8d00b0068e3fe62c82mr298486pfv.34.1695409718924; Fri, 22 Sep 2023 12:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695409718; cv=none; d=google.com; s=arc-20160816; b=cLmHjTISO5d/yrc38UgsrM76bxyHJQdYCB/mxejGQ8AAOLWbk4IT5cOgcjryUkMncd YPnHNuyFZaDbpu0U/N0XG9SqgDl6FjrE3wxHFWF+wH2SWpW9TkZNiXTHphjDlT5qyFZ+ TEArWOT4oa97e6fiUY9WwuwBwzN+z3p2T9yOTuPpBspWxaPQ2BsgD11tucDf0+5oyTNt b8hjoLiCEhZ8JH36h+b5tCGaXGivTOl3oc/7lDkk9L+xk+lHbBdRr6ei/N+jMYZ287Ui 1agnWZIc9sZ0+vkQKV8xe4pKoG8otwPJGr9C268uKIoHE9THSTLzrF3AU9Ppyi+AMBzo YqpQ== 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=FCKdl+TDCA+seofTtpnn84sB2NdPr1YjMxmJkFSOMIg=; fh=J+iFXvHUbStFrBktvFnqRKdg784OABtOz/QMCCPbZpw=; b=aHZ5JGiooVl2tsT1D7R76XWip2JEwZIiMdYk30kYbqcFngonsbogGeb2v0AyYycB10 6YiyjMYl+Ly7QpBwMlzdHnm4EWr34JMVUpX/1bsK1uL/VDEb/puqs9dBzDryJfCG0Scq k/THaUiEBgmLD7uFRKphIoDTY4Gk9FWP3Mj4sTYnQM2psxSFXZvSVFKBxq8QUynmt5kZ 7PGa4uYGuSVFqraGmVj1XWdMgiplmqlc7ngR3rGRSmMy6YBuOEY6GN75QgsnASnHqJcx xBU9XfinXXXGw/dSOWeHVDiB72I0Aci1vgupaT0JwKpgYRuXg/tp4iszDESHTHCjma7M VKYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Yn51I8ol; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id s20-20020a656454000000b00578db71451fsi4335100pgv.501.2023.09.22.12.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 12:08:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Yn51I8ol; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3241683AA3A6; Fri, 22 Sep 2023 12:08:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233798AbjIVTIa (ORCPT + 99 others); Fri, 22 Sep 2023 15:08:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231209AbjIVTI3 (ORCPT ); Fri, 22 Sep 2023 15:08:29 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBA73AF; Fri, 22 Sep 2023 12:08:22 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58817C433CA; Fri, 22 Sep 2023 19:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695409702; bh=gXlMQDEZcoZ7YEdGgWtE3RZREDwAT02Now/rm1ivZ38=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Yn51I8olnoubAb0raQHBCIT/zuvl9y8bpUwUhW4/RuV1vBKOEJIHZExnNP74ixNNq 5EMJNRRHOPZ9XNf4YH8gu7TPlZ6gRMATOpnrQrrQTTAcNlMVGU2VYGikwcO96OMKw/ SwVHFIUtHDdgastpbwVyr0G0oKbcDgrRqW/Jep9PVc229s31lwYPV+FZEIrAqrW/xQ Wa7kmcEcWrQw2JYhOdVCP32VbZfQJkzERteI+UAjEboN9+9pq7xfA8c0fDzgd7kMtx u0aC5tt+HCeWDIs1QMlzZ2UDhqjXWmgoyJmYYjPfn722bKAp/Hc5bpFf7mbPdOajXb 7gVLhp5zWmvmg== Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5042f391153so3273150e87.1; Fri, 22 Sep 2023 12:08:22 -0700 (PDT) X-Gm-Message-State: AOJu0YxNayVulqzNmFinVTXyOz5R8nWAiJD4U0Znunx8a6Gyh7qCB1FO 5hNULuoem+2xPYvIDjE5zfd5SGhB/oO9WaLDjA== X-Received: by 2002:a05:6512:2356:b0:503:385d:611b with SMTP id p22-20020a056512235600b00503385d611bmr1315873lfu.30.1695409700475; Fri, 22 Sep 2023 12:08:20 -0700 (PDT) MIME-Version: 1.0 References: <20230921102420.RFC.1.I9dddd99ccdca175e3ceb1b9fa1827df0928c5101@changeid> In-Reply-To: From: Rob Herring Date: Fri, 22 Sep 2023 14:08:08 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] of: device: Support 2nd sources of probeable but undiscoverable devices To: Doug Anderson Cc: Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, Benjamin Tissoires , Chen-Yu Tsai , linux-input@vger.kernel.org, Jiri Kosina , Hsin-Yi Wang , linux-gpio@vger.kernel.org, linus.walleij@linaro.org, Dmitry Torokhov , Johan Hovold , andriy.shevchenko@linux.intel.com, broonie@kernel.org, frowand.list@gmail.com, gregkh@linuxfoundation.org, hdegoede@redhat.com, james.clark@arm.com, james@equiv.tech, keescook@chromium.org, linux-kernel@vger.kernel.org, rafael@kernel.org, tglx@linutronix.de Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 22 Sep 2023 12:08:35 -0700 (PDT) X-Spam-Level: ** On Fri, Sep 22, 2023 at 12:40=E2=80=AFPM Doug Anderson wrote: > > Hi, > > On Fri, Sep 22, 2023 at 7:14=E2=80=AFAM Rob Herring = wrote: > > > > > Let's attempt to do something better. Specifically, we'll allow > > > tagging nodes in the device tree as mutually exclusive from one > > > another. This says that only one of the components in this group is > > > present on any given board. To make it concrete, in my proposal this > > > looks like: > > > > > > / { > > > tp_ex_group: trackpad-exclusion-group { > > > }; > > > > Interesting way to just get a unique identifier. But it could be any > > phandle not used by another group. So just point all the devices in a > > group to one of the devices in the group. > > Fair enough. > > > > > &i2c_bus { > > > tp1: trackpad@10 { > > > ... > > > mutual-exclusion-group =3D <&tp_ex_group>; > > > }; > > > tp2: trackpad@20 { > > > ... > > > mutual-exclusion-group =3D <&tp_ex_group>; > > > }; > > > tp3: trackpad@30 { > > > ... > > > mutual-exclusion-group =3D <&tp_ex_group>; > > > }; > > > }; > > > > > > In Linux, we can make things work by simply only probing one of the > > > devices in the group at a time. We can make a mutex per group and > > > enforce locking that mutex around probe. If the first device that get= s > > > the mutex fails to probe then it won't try again. If it succeeds then > > > it will acquire the shared resources and future devices (which we kno= w > > > can't be present) will fail to get the shared resources. Future > > > patches could quiet down errors about failing to acquire shared > > > resources or failing to probe if a device is in a > > > mutual-exclusion-group. > > > > This seems like overkill to me. Do we really need groups and a mutex > > for each group? Worst case is what? 2-3 groups of 2-3 devices? > > Instead, what about extending "status" with another value > > ("fail-needs-probe"? (fail-xxx is a documented value)). Currently, the > > kernel would just ignore nodes with that status. Then we can process > > those nodes separately 1-by-1. > > My worry here is that this has the potential to impact boot speed in a > non-trivial way. While trackpads and touchscreens _are_ probable, > their probe routines are often quite slow. This is even mentioned in > Dmitry's initial patches adding async probe to the kernel. See commit > 765230b5f084 ("driver-core: add asynchronous probing support for > drivers") where he specifically brings up input devices as examples. Perhaps then this should be solved in userspace where it can learn which device is actually present and save that information for subsequent boots. > It wouldn't be absurd to have a system that has multiple sources for > both the trackpad and the touchscreen. If we have to probe each of > these one at a time then it could be slow. It would be quicker to be > able to probe the trackpads (one at a time) at the same time we're > probing the touchscreens (one at a time). Using the "fail-needs-probe" > doesn't provide information needed to know which devices conflict with > each other. I would guess most of the time that's pretty evident. They are going to be on the same bus/link. If unrelated devices are on the same bus, then that's going to get serialized anyways (if bus accesses are what make things slow). We could add information on the class of device. touchscreen and touchpad aliases or something. > IMO this is still better than nothing, but it worries me > to pick the less-expressive solution for the dts which means that the > information simply isn't there and the OS can't be made better later. > > Thinking about this more, I guess even my proposed solution isn't > ideal for probe speed. Let's imagine that we had: > > &i2c_bus { > tp1: trackpad@10 { > compatible =3D "hid-over-i2c"; > reg =3D <0x10>; > post-power-on-delay-ms =3D <200>; > ... > mutual-exclusion-group =3D <&tp1>; > }; > tp2: trackpad@20 { > compatible =3D "hid-over-i2c"; > reg =3D <0x20>; > post-power-on-delay-ms =3D <200>; > ... > mutual-exclusion-group =3D <&tp1>; > }; > }; > > With my solution, we'd power the first device up, wait 200 ms, then > check to see if anything acks an i2c xfer at address 0x10. If it > didn't, we'd power down. Then we'd power up the second device > (presumably the same power rail), wait 200 ms, and check to see if > anything acks an i2c xfer at 0x20. It would have been better to just > power up once, wait 200 ms, then check for a device at either 0x10 or > 0x20. > > I guess with more complex touchscreens this could be more important. I > don't know if we need to try to solve it at this point, but I guess I > could imagine a case where we truly need to take into account all > possible devices (maybe taking the maximum of delays?) to ensure we > don't violate power sequencing requirements for any of them while > probing. > > That would lead me to suggest this: > > &i2c_bus { > trackpad-prober { > compatible =3D "mt8173-elm-hana-trackpad-prober"; > > tp1: trackpad@10 { > compatible =3D "hid-over-i2c"; > reg =3D <0x10>; > ... > post-power-on-delay-ms =3D <200>; > }; > tp2: trackpad@20 { > compatible =3D "hid-over-i2c"; > reg =3D <0x20>; > ... > post-power-on-delay-ms =3D <200>; > }; > }; > }; > > ...but I suspect that would be insta-NAKed because it's creating a > completely virtual device ("mt8173-elm-hana-trackpad-prober") in the > device tree. I don't know if there's something that's functionally > similar that would be OK? Why do you need the intermediate node other than a convenient way to instantiate a driver? You just need a flag in each node which needs this special handling. Again, "status" could work well here since it keeps the normal probe from happening. But I'm not saying you can't have some board specific code. Sometimes you just need code to deal with this stuff. Don't try to parameterize everything to DT properties. Note that the above only works with "generic" compatibles with "generic" power sequencing properties (I won't repeat my dislike again). If only the driver knows how to handle the device, then you still just have to have the driver probe. If you *only* wanted to solve the above case, I'd just make "hid-over-i2c" take a 2nd (and 3rd) I2C address in reg and have those as fallbacks. You could always make the driver probe smarter where if your supply was already powered on, then don't delay. Then something else could ensure that the supply is enabled. I'm not sure if regulators have the same issue as clocks where the clock might be on from the bootloader, then a failed probe which gets then puts the clock turns it off. Rob