From patchwork Thu Sep 2 23:04:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 506710 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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham 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 E333BC433EF for ; Thu, 2 Sep 2021 23:04:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5D1E610A0 for ; Thu, 2 Sep 2021 23:04:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232548AbhIBXFs (ORCPT ); Thu, 2 Sep 2021 19:05:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244682AbhIBXFs (ORCPT ); Thu, 2 Sep 2021 19:05:48 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51EA5C061575 for ; Thu, 2 Sep 2021 16:04:49 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id et12-20020a056214176c00b0037279a2ce4cso4441405qvb.13 for ; Thu, 02 Sep 2021 16:04:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=EzWN+e8Z1YBfv4DI3mOenbfA5vwz77klczIXE4gMJG8=; b=H/u4rLaENOC4NRXolWAJG1BEVesOUaKcyjVQyvOKujZopwYDjWEazEDGqRQWy+abkv Vqn/7Fela1LOT9fjRrxb6LIBn+MXOOgMeeFkR4EUtrqU7ERTdjHi5C0u9de2J8GD7yaQ 3hTGTgymYoSKuek/e0TdwkivXKvZ/qFZk+fO9ECGOGN6Qns6O2iJCHiRBq9NvPAR8wFz s1pIXfPe9BItQwRad2sn5dd5J5PJB8b7DG2e9WGnjKPwQYOzUoEXIuDN9t9HeO1tF0uo VCypSX+cbO0J79CfmplZHKL7Q2YGyeUVfG/rMBRJQZvDmGLdOw841k7znnGQoG3SDhlR mvMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=EzWN+e8Z1YBfv4DI3mOenbfA5vwz77klczIXE4gMJG8=; b=EgMcq7/UOQm6WWdMlnCDLIE8LUCe8lG4KX0KvcuIIOMt0wv2wFDMpnSR06NTzULqLS 946ed3YCOB9Ni0zn5fL472eAaItsWDXVL3oWiLWYHcuPdD1zEC4CqAc0B0UjKm+HAhdL J9z/ueshMSicnGp7Wl35WQlx9LSLiqKb0SMyO1erAOFFlpXoNmQE6FUXQ8vYxzYVfjyx H0+hydvoeiYu8wtS+3gDAY9+P9DuWIWyNFMxD5Cx27qpmTxRHXY6dnqGOdERn71qvw4E cPRmefenZj2G65Fc+OPPLLfo07Ie3f4544bKNSEMo+HVQfSHmIQy/quPzFPo93ErlBbW LUgQ== X-Gm-Message-State: AOAM530FzG6ZsrnuJURhpa//YOxhEXxUvgb84ogj9yHrSnAMX3jWxwa+ rCOoFhTiVKRBBGqnDkCtnTZCBbu0KnDkFZo= X-Google-Smtp-Source: ABdhPJyMqvlBqqp1YK5/YEtU2oGozc6mjbpZipwjtwEhTxnBYpLaUPMIgwdvUtn/2nDF+EclWV6MwTPtxGwOJvw= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:7cb7:1ee7:33cb:da76]) (user=saravanak job=sendgmr) by 2002:a05:6214:130a:: with SMTP id a10mr632215qvv.53.1630623888488; Thu, 02 Sep 2021 16:04:48 -0700 (PDT) Date: Thu, 2 Sep 2021 16:04:40 -0700 In-Reply-To: <20210902230442.1515531-1-saravanak@google.com> Message-Id: <20210902230442.1515531-2-saravanak@google.com> Mime-Version: 1.0 References: <20210902230442.1515531-1-saravanak@google.com> X-Mailer: git-send-email 2.33.0.153.gba50c8fa24-goog Subject: [PATCH v2 1/2] of: platform: Make sure bus only devices get probed From: Saravana Kannan To: Rob Herring , Frank Rowand Cc: Saravana Kannan , Ulf Hansson , Geert Uytterhoeven , kernel-team@android.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org fw_devlink could end up creating device links for bus only devices. However, bus only devices don't get probed and can block probe() or sync_state() [1] call backs of other devices. To avoid this, set up these devices to get probed by the simple-pm-bus. [1] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/ Signed-off-by: Saravana Kannan Tested-by: Saravana Kannan --- drivers/of/platform.c | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 74afbb7a4f5e..b010e2310131 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -97,6 +97,48 @@ static void of_device_make_bus_id(struct device *dev) } } +/** + * of_match_only_simple_bus - Check if a device node is only a simple bus + * @np: device node to check + * + * A simple bus in this context is defined as a transparent bus whose child + * devices are automatically populated but has no hardware specific + * functionality. + * + * Returns true if the device node is only a simple bus and can never match + * with any other specific driver. Otherwise, returns false. + */ +static bool of_match_only_simple_bus(struct device_node *np) +{ + /* List of buses that don't have an explicit driver. */ + static const char * const of_simple_bus_table[] = { + "simple-bus", + "simple-mfd", + "isa", + "arm,amba-bus", + }; + const char *cp; + struct property *prop; + int i; + + prop = of_find_property(np, "compatible", NULL); + for (cp = of_prop_next_string(prop, NULL); cp; + cp = of_prop_next_string(prop, cp)) { + bool match = false; + const char *bus = of_simple_bus_table[i]; + + for (i = 0; i < ARRAY_SIZE(of_simple_bus_table); i++) + if (!of_compat_cmp(cp, bus, strlen(bus))) { + match = true; + break; + } + if (!match) + return false; + } + + return true; +} + /** * of_device_alloc - Allocate and initialize an of_device * @np: device node to assign to device @@ -143,6 +185,9 @@ struct platform_device *of_device_alloc(struct device_node *np, dev->dev.fwnode = &np->fwnode; dev->dev.parent = parent ? : &platform_bus; + if (of_match_only_simple_bus(np)) + dev->driver_override = "simple-pm-bus"; + if (bus_id) dev_set_name(&dev->dev, "%s", bus_id); else