Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2135064pxb; Sat, 23 Jan 2021 18:56:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxTRBFbWhybNiyZk7PFQAq4Lqp0B9uUO3sD7OgzkLXJyY6R9EZOQYcu7k++bVJCuMq1Oc4 X-Received: by 2002:a05:6402:31bb:: with SMTP id dj27mr142423edb.285.1611456962524; Sat, 23 Jan 2021 18:56:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611456962; cv=none; d=google.com; s=arc-20160816; b=Jmoe34hAMPH19ox51lsT1hY4Ijjh+UnCjfMspbTSP5mhh0a6Gji+vRaJfjxappZH4e 554y/reMQtmm1xqcEQDbwsaXGJmwL4H0zJRDT5SnurhR7MjThjuim2EjMSACKOr1ZHx8 Y684ecOs4SgPlrEHhzlHmRnF7EmLb5KIgg4iXKIgWFRZwTulomHM+fHMsJdws2n+IMwN Y05Ozj/41NDn6xp8p28O5XKX6JB7A+KIJ5qxT7PGHx+qY3sl+23p8eoOKzWZ+Tos9wwb KQGmDEZjiN5few7xxRfoaAHaiae7jEv8tLCELOV3ny6WPgyNJKCLEnJSTixx+8g3E5vH flXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=TbF3Lbs9wpNVllm6ynkRXy8qTf3NddpOylwzWmHrUp0=; b=r3pCVP+xw8soF6SKO3KTTU+viezu8XyLiO9OPV5btxM/AizPWcsCbcVtuM4qBkgrL/ 8YLI1jWB/6e38mO1D8JPDQfDVrUlQKHzGVzGAI3zapweBnoPhQFlipiQeJ/8oa2+E5Zg HaA2a/+MChSwFy3CtF/ZHLqwiA8ZEfFJ3yqCGKKxliYSy/UAjYunv8I55mI06lAPjj7G 2U+TgRVAIYLh7GW4F7/GqLETYe7+RZwkHSWHyiUMhnS1W2URzrwu1p7KoyWMYgTGhglN kaF6X5tuPElm/nTWedC6gAtUlEBfJihKNIFONNI1PzZJSgdyB/AoY+IT+n0+dFNNd61i 9H7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rzIW9DL2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn23si5372026edb.27.2021.01.23.18.55.39; Sat, 23 Jan 2021 18:56:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rzIW9DL2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726367AbhAXCzN (ORCPT + 99 others); Sat, 23 Jan 2021 21:55:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725943AbhAXCzM (ORCPT ); Sat, 23 Jan 2021 21:55:12 -0500 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EDB7C0613D6 for ; Sat, 23 Jan 2021 18:54:32 -0800 (PST) Received: by mail-yb1-xb35.google.com with SMTP id x6so9751269ybr.1 for ; Sat, 23 Jan 2021 18:54:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TbF3Lbs9wpNVllm6ynkRXy8qTf3NddpOylwzWmHrUp0=; b=rzIW9DL2YyNS6cO4zCkvKWTJYxqf1OJVsJp7/Fd9wkR1+gybMnazGjMskGej1BV2bM 0Wzf0JfoZB6zbsckVB0KY2dAKu+dh6xKj5ET4mEDbDyro+ihxMHz2jN/6tzLii+2Hpsj 09NdjeRmjmQjJDknDSjjuEmLBKJQq/NvIRYd8hKg7slQQ7Zlq4yzdPN4FPeftvhtnFZL QXSj4gn4/+rh0nT2kyxkZP+mj1jgjEm46iJ+M55gxzjD/iEHHRL552hDfbStFpEZMTJ7 ++gLJm4BlwWx+iRrn/ayXa7TlPYsSB1aPZcEogWwu4h99i5YQ9kdbgToXEWdR4JtLXni jNmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TbF3Lbs9wpNVllm6ynkRXy8qTf3NddpOylwzWmHrUp0=; b=fc8loCPKeYu0T5bfv5oef0bSTIxrzx2IuJ/FtOHJswgSJGYm9HlY/PTilygi1aEIds duOOIM1x2vcktjIyVcabdC5AwtVEv1MvQsrqgBhy212+aHHgyRoRM//gB6s/WD3jpYkB wIBw5g66mosN951TsX34dzfD+pOkW8ydFXmNYssiPTpaIYDH00Bw1nheuzdiiAFBzO0m zgKQJDdl3XNDil4P33ScLu6iK1nMrL8Gw0ilj/anh/9BCzfGaaEj1/nqO80eK5ynlCW0 wqCTd8FZVpW49tvqdZlvAIkaT8DQMsou5d5b28y8xn9ZMPWtLdUwGLflPyq52KdYA7yy ZJ4A== X-Gm-Message-State: AOAM530mJNnHjo+6XIXbmmhxcLf59eggQLP0G+QmAX721MfGrAt8soOt 10H9gpouvryyVvq7DCyYrQte9SgjN9Y+kN4OLlyJvQ== X-Received: by 2002:a25:dfcb:: with SMTP id w194mr15547389ybg.346.1611456871043; Sat, 23 Jan 2021 18:54:31 -0800 (PST) MIME-Version: 1.0 References: <20210122193600.1415639-1-saravanak@google.com> In-Reply-To: From: Saravana Kannan Date: Sat, 23 Jan 2021 18:53:55 -0800 Message-ID: Subject: Re: [PATCH v5] gpiolib: Bind gpio_device to a driver to enable fw_devlink=on by default To: Linus Walleij Cc: Bartosz Golaszewski , Greg Kroah-Hartman , Marc Zyngier , Jisheng Zhang , Kever Yang , Android Kernel Team , "open list:GPIO SUBSYSTEM" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 23, 2021 at 2:52 PM Linus Walleij wrote: > > On Fri, Jan 22, 2021 at 8:36 PM Saravana Kannan wrote: > > > There are multiple instances of GPIO device tree nodes of the form: > > > > foo { > > compatible = "acme,foo"; > > ... > > > > gpio0: gpio0@xxxxxxxx { > > compatible = "acme,bar"; > > ... > > gpio-controller; > > }; > > > > gpio1: gpio1@xxxxxxxx { > > compatible = "acme,bar"; > > ... > > gpio-controller; > > }; > > > > ... > > } > > > > bazz { > > my-gpios = <&gpio0 ...>; > > } > > > > Case 1: The driver for "foo" populates struct device for these gpio* > > nodes and then probes them using a driver that binds with "acme,bar". > > This driver for "acme,bar" then registers the gpio* nodes with gpiolib. > > This lines up with how DT nodes with the "compatible" property are > > typically converted to struct devices and then registered with driver > > core to probe them. This also allows the gpio* devices to hook into all > > the driver core capabilities like runtime PM, probe deferral, > > suspend/resume ordering, device links, etc. > > > > Case 2: The driver for "foo" doesn't populate struct devices for these > > gpio* nodes before registering them with gpiolib. Instead it just loops > > through its child nodes and directly registers the gpio* nodes with > > gpiolib. > > > > Drivers that follow case 2 cause problems with fw_devlink=on. This is > > because fw_devlink will prevent bazz from probing until there's a struct > > device that has gpio0 as its fwnode (because bazz lists gpio0 as a GPIO > > supplier). Once the struct device is available, fw_devlink will create a > > device link with gpio0 device as the supplier and bazz device as the > > consumer. After this point, since the gpio0 device will never bind to a > > driver, the device link will prevent bazz device from ever probing. > > > > Finding and refactoring all the instances of drivers that follow case 2 > > will cause a lot of code churn and it is not something that can be done > > in one shot. In some instances it might not even be possible to refactor > > them cleanly. Examples of such instances are [1] [2]. > > > > This patch works around this problem and avoids all the code churn by > > simply setting the fwnode of the gpio_device and creating a stub driver > > to bind to the gpio_device. This allows all the consumers to continue > > probing when the driver follows case 2. > > > > [1] - https://lore.kernel.org/lkml/20201014191235.7f71fcb4@xhacker.debian/ > > [2] - https://lore.kernel.org/lkml/e28e1f38d87c12a3c714a6573beba6e1@kernel.org/ > > Cc: Marc Zyngier > > Cc: Jisheng Zhang > > Cc: Kever Yang > > Fixes: e590474768f1 ("driver core: Set fw_devlink=on by default") > > Signed-off-by: Saravana Kannan > > This v5 version is a beauty! Lol, thanks. > Reviewed-by: Linus Walleij Considering the "Fixes" is only in driver-core-next, should this go through driver-core? -Saravana