From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7CEBC433DF for ; Thu, 15 Oct 2020 16:52:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 682E02225D for ; Thu, 15 Oct 2020 16:52:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SDoAAQkW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731061AbgJOQwz (ORCPT ); Thu, 15 Oct 2020 12:52:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730137AbgJOQwz (ORCPT ); Thu, 15 Oct 2020 12:52:55 -0400 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8670CC0613D2 for ; Thu, 15 Oct 2020 09:52:55 -0700 (PDT) Received: by mail-yb1-xb42.google.com with SMTP id h9so2817120ybm.4 for ; Thu, 15 Oct 2020 09:52:55 -0700 (PDT) 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=kMr40LI/hXcWSQOOPZsCuoJBcw+0XKBqS6dhgqIQMko=; b=SDoAAQkWLCC2CkjWAeHxvm15SKFsOztI8gbQF02ZA9606gUcHwv/NfHe/aWdYXy0f+ IIE0nZgGXJfdssTpvo3/MzvXFGaks0dvKHV4q37EbIQ6BrHTZXU704YMuo6PbLuv3UUU JF66q1OHUVsABa2fRI0XBdDlKTcfCCmLfnsRq0Xj6PEPsp1f8zXXhx1fcf4nYXM6qqLN H3mCx56zOs41I0md0TPtr5kz9jgePYIiaUn/iBc8ERntQ3FPbE+8sSng7BwJiZ+ND2vm fOLBD3NmbEE9HMo0Ebq7Mg8PvMFcewF85ASCRWpQw9GkzTcNKUe/PSyIx9hb69Q52hFi 3oyQ== 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=kMr40LI/hXcWSQOOPZsCuoJBcw+0XKBqS6dhgqIQMko=; b=Ql1Jahtk34Kr0bAO3TVwBBR00SMFOZPdahI3Wai1XR6C5o8G2zXCS57d6IoMOttTjv 0TIbZ7eQQoyIk0oQJKV5cJSwTGXkbiHjUIG0Vzn9RSyxQk2jk4K9bee+Ql8pUc2yetWE 1SGzUlvQ3pb+6CVkmnIBED3ZcjEpah/wVv7PnEpMjR/pxHoLtR0DUgTekV90HbwncwKf 2itJ/3TFQmsPM/P2vU/YH3UL8bGDm6YXn9c/1qzHZU8HLpIFCTK6FKZ7Cgt98DEhquyR +z40IT8JyRVmYH+N5LtryEqe/0KB6mlcaJtYeT8pLvCN8M57DHYemPDvS1ljyznrjmJ2 QhQQ== X-Gm-Message-State: AOAM5315MJTSQ/oSkNxwSh13AEPeOllNCaQ4JkciyEmyIh92EIylHYXr 12Bc+xpPjga5BOLgbBNMgaYBsWD6r/Be8wBIghQnVw== X-Google-Smtp-Source: ABdhPJxCJTI4uchgyYaGQsVOXlattOcLY8lElgxdbtmYlmczpvbLirt51rqV00R+R7TNCDkQtdynZAIl6CZQmMot53U= X-Received: by 2002:a25:380c:: with SMTP id f12mr7111559yba.32.1602780774204; Thu, 15 Oct 2020 09:52:54 -0700 (PDT) MIME-Version: 1.0 References: <20201015114346.15743-1-nsaenzjulienne@suse.de> In-Reply-To: <20201015114346.15743-1-nsaenzjulienne@suse.de> From: Saravana Kannan Date: Thu, 15 Oct 2020 09:52:18 -0700 Message-ID: Subject: Re: [RFC] of/platform: Create device link between simple-mfd and its children To: Nicolas Saenz Julienne Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , f.fainelli@gmail.com, linux-rpi-kernel@lists.infradead.org, u.kleine-koenig@pengutronix.de, "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Thu, Oct 15, 2020 at 4:43 AM Nicolas Saenz Julienne wrote: > > 'simple-mfd' usage implies there might be some kind of resource sharing > between the parent device and its children. By creating a device link > with DL_FLAG_AUTOREMOVE_CONSUMER we make sure that at no point in time > the parent device is unbound while leaving its children unaware that > some of their resources disappeared. Doesn't the parent child relationship already ensure that? If not, maybe that's what needs fixing? > Signed-off-by: Nicolas Saenz Julienne > > --- > > Some questions: > > - To what extent do we care about cleanly unbinding platform devices at > runtime? My rationale here is: "It's a platform device, for all you > know you might be unbinding someting essential to the system. So if > you're doing it, you better know what you're doing." > > - Would this be an abuse of device links? Feels like it. > > - If applying this to all simple-mfd devices is a bit too much, would > this be acceptable for a specific device setup. For example RPi4's > firmware interface (simple-mfd user) is passed to consumer drivers > trough a custom API (see rpi_firmware_get()). So, when unbound, > consumers are left with a firmware handle that points to nothing. You can always create device link between the real suppliers and consumers. > > drivers/of/platform.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/of/platform.c b/drivers/of/platform.c > index b557a0fcd4ba..8d5b55b81764 100644 > --- a/drivers/of/platform.c > +++ b/drivers/of/platform.c > @@ -390,8 +390,14 @@ static int of_platform_bus_create(struct device_node *bus, > } > > dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent); > - if (!dev || !of_match_node(matches, bus)) > - return 0; > + if (!dev) > + return 0; > + > + if (parent && of_device_is_compatible(parent->of_node, "simple-mfd")) > + device_link_add(&dev->dev, parent, DL_FLAG_AUTOREMOVE_CONSUMER); > + > + if (!of_match_node(matches, bus)) > + return 0; Even if we think we should add this between parent and child (this still seems like not a good place to do it). Matching it by compatible string and doing special stuff doesn't feel right inside here. -Saravana > > for_each_child_of_node(bus, child) { > pr_debug(" create child: %pOF\n", child); > -- > 2.28.0 >