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 From patchwork Thu Sep 2 23:04:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 505833 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 1B27DC433F5 for ; Thu, 2 Sep 2021 23:04:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 025D7610A1 for ; Thu, 2 Sep 2021 23:04:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348530AbhIBXFv (ORCPT ); Thu, 2 Sep 2021 19:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348529AbhIBXFu (ORCPT ); Thu, 2 Sep 2021 19:05:50 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE33DC061575 for ; Thu, 2 Sep 2021 16:04:51 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id f64-20020a2538430000b0290593bfc4b046so4524567yba.9 for ; Thu, 02 Sep 2021 16:04:51 -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=fE4xWbnNUsaH2L2+9e5Jc7xWeW6lJkVzW9cJr5tZCTo=; b=H+Pvky7XU9ApAtzwgpgQVBA1tHgUZtMeP5w3daltJpilyFci7Rzq5wpVDReU38JFzr 4YfB0wERKVKz4KGFlZPTfMGyn+JCX1VswHHkFPf8bN16ODi9e3hY0BevWI5Tz2QcTMug +diSdJBgTG73ywUdQT4hqxzOnYeqhWWaJCdFxLzBXqYuMfowNu4XNAREsttUCS5K58Cd LWpqkJfAwbIIOYOA0dUwhrTTyxy8qdK41/dzkGdKYrSSancrEiR4xCtKW2uNlnnn6C5C CyjniDyeQaxbraSES6WCwQyI9mbjsUeNSaYLyopI1U383UCtHrmM1a18KMJ1dex7LDwT 0NgA== 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=fE4xWbnNUsaH2L2+9e5Jc7xWeW6lJkVzW9cJr5tZCTo=; b=uF8P3d0vilPul1dIKB0fJrV/9M3Tp4qAuAQTQEfMWWYNZcRwt+ntls1LGzGXoKHgB2 qgih+sJgdd4KFhKLbl7AmfkijJKI1fa46NESsC7Ep4ldI5+lNFH5Z1VWEx0DZ4N1xwfW VMdLOu/vZJFNyNkl4ZgzIfCne1phXmnmkb67x28mjxJUoVasBCtkACKy4a47e13l+ZLk 1MLbNoylxcrj88DZn+lCws6wZy8aBL3Zjhy4iyVtLEuejPiK2YboKaqUMoQuJVzqftcH B+6ewfPKeahp9LkStqtZlSheHH3fl9T19KkxOIuFBOBB5A6RfvPkKGr6R08Y4fY6+oLV 3Bnw== X-Gm-Message-State: AOAM533UJrtM98OdjU3ALncYxbE4lMyCw3R5r1uxoA218jQJhPTASfkh yPXWaheTo8xZ9CtgForGsjB65RpojR/AKo8= X-Google-Smtp-Source: ABdhPJxWgcYcIBBK376uC3gnVCUb/S4Lj9Rk7QhgF79UpRu0Ye+Nb1O88qm7IOAAT/bpyFwsdRjCxBFBgy1vRQc= X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:7cb7:1ee7:33cb:da76]) (user=saravanak job=sendgmr) by 2002:a25:1bc6:: with SMTP id b189mr1031877ybb.338.1630623890909; Thu, 02 Sep 2021 16:04:50 -0700 (PDT) Date: Thu, 2 Sep 2021 16:04:41 -0700 In-Reply-To: <20210902230442.1515531-1-saravanak@google.com> Message-Id: <20210902230442.1515531-3-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 2/2] drivers: bus: simple-pm-bus: Add support for probing simple bus only devices 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 The OF platform code sets up simple bus only devices (i.e. devices that won't match with any other driver) to get probed by the simple-pm-bus to keep fw_devlink from blocking probe() or sync_state() [1] callbacks of other devices. There's no need to populate the child devices since the OF platform code would do that anyway, so return early for these simple bus only devices. [1] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/ Signed-off-by: Saravana Kannan Tested-by: Saravana Kannan --- drivers/bus/simple-pm-bus.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c index 01a3d0cd08ed..91d52021b7f9 100644 --- a/drivers/bus/simple-pm-bus.c +++ b/drivers/bus/simple-pm-bus.c @@ -19,6 +19,13 @@ static int simple_pm_bus_probe(struct platform_device *pdev) const struct of_dev_auxdata *lookup = dev_get_platdata(&pdev->dev); struct device_node *np = pdev->dev.of_node; + /* + * These are transparent bus devices (not simple-pm-bus matches) that + * get populated automatically. So, don't need to do anything more. + */ + if (pdev->driver_override) + return 0; + dev_dbg(&pdev->dev, "%s\n", __func__); pm_runtime_enable(&pdev->dev);