Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3028546pxb; Mon, 18 Oct 2021 06:55:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD62ZqE21/G1Kyzj5BoXaBCj29hzK/o11iTS0usKfTS0toAN2ebm6sxoOEhBAyk7v5cVOz X-Received: by 2002:a63:1444:: with SMTP id 4mr23470338pgu.251.1634565327985; Mon, 18 Oct 2021 06:55:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565327; cv=none; d=google.com; s=arc-20160816; b=wt3SoIfCo9qCN1q4VHn0rH5mE3u3JSzZY0eL4M4TK9YEwTxnaMvm3rkUkJ7ePN6AX3 i92xAGsED49FQy/m4NAK9Z9yKromYxXEOrh4RBrWUSJdM1laWSKTD5vnjfpKswySprfm pLCZpMHIiHL8KxhHHNYuRK6KsF3FnN0WWwjFvOata7ZfevlfxGxsMiMhO5a5p33FWGYN OFaxISo4CZxsSo8H6T1+tJ1y2qk60cj7Id/JtLyFXkFiTwjoqdvdgn56k3dz/ih6LBM0 9IBnOzETdrQhiUihrkm3poeoHM8JvUsCKC6R6TAuZW/cxYnFVEGmzgj7I88xB2PgGFS5 ZXoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9mRu7Bm0jaRAl54NBlXehK8se8S/WZZGOh8woCBOwB4=; b=armaLlsuw5zHNWf/eZlmQ5GS/SUwFJTaDaZkgvrY85fZtV9mP0drEPPlPpZfGBDqRc PvRdas1kuVc9PkyR6+z4j08LDPyh7lyCqAnxPL7cgA85KdBsER2gt4E+C/TfoKmYMWfD Fo46uQvfuVozm61yG7hjq8aL3IhKbb3haDDu1SVs3TWL6ui4wPRptHIxm/4hMHvNwVyd roCLySOqkNajXdV68Jcqd49f6WYp075djjCI8JIDw4QVIdoror6Cr93X35FshFrlO/OJ E1T/z/VJG42cctllG0CeDRNeT2rmHJQZaXA1hQ25VSuEAjMdTyrrk02/VH3uSRawyNE+ RGgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=msJp28ma; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y71si10236038pgd.574.2021.10.18.06.55.15; Mon, 18 Oct 2021 06:55:27 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=msJp28ma; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233467AbhJRN42 (ORCPT + 99 others); Mon, 18 Oct 2021 09:56:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:59334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233691AbhJRNyb (ORCPT ); Mon, 18 Oct 2021 09:54:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8BFC361A08; Mon, 18 Oct 2021 13:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564380; bh=4Cr/LUXS6/p3aQyEQVDy0YEd/nyBo0uqSPeY8q311Ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=msJp28mam3hPM3KJp3EKVCyY3EAOeP6FuyfVfoc1xpyyJhRpeKLupkt1YkFddwkdS sjg/luSLRnjH/ShnPWCfXdG1d9JNo1crY2urCk9eMKXd77nWB+VdqPwWN4JIcmhdMu Lw69VVM5BGiZn9LSM3HDib4lqiTjCagyozBuVFic= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rob Herring , Saravana Kannan , Ulf Hansson , Geert Uytterhoeven , Damien Le Moal Subject: [PATCH 5.14 066/151] drivers: bus: simple-pm-bus: Add support for probing simple bus only devices Date: Mon, 18 Oct 2021 15:24:05 +0200 Message-Id: <20211018132342.837682197@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Saravana Kannan commit 98e96cf80045a383fcc47c58dd4e87b3ae587b3e upstream. 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, probe these devices using the simple-pm-bus driver. However, there are instances of devices that are not simple buses (they get probed by their specific drivers) that also list the "simple-bus" (or other bus only compatible strings) in their compatible property to automatically populate their child devices. We still want these devices to get probed by their specific drivers. So, we make sure this driver only probes devices that are only buses. [1] - https://lore.kernel.org/lkml/CAPDyKFo9Bxremkb1dDrr4OcXSpE0keVze94Cm=zrkOVxHHxBmQ@mail.gmail.com/ Fixes: c442a0d18744 ("driver core: Set fw_devlink to "permissive" behavior by default") Cc: stable Cc: Rob Herring Tested-by: Saravana Kannan Tested-by: Ulf Hansson Tested-by: Geert Uytterhoeven Tested-by: Damien Le Moal Signed-off-by: Saravana Kannan Link: https://lore.kernel.org/r/20210929000735.585237-2-saravanak@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/bus/simple-pm-bus.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) --- a/drivers/bus/simple-pm-bus.c +++ b/drivers/bus/simple-pm-bus.c @@ -13,11 +13,36 @@ #include #include - 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; + const struct device *dev = &pdev->dev; + const struct of_dev_auxdata *lookup = dev_get_platdata(dev); + struct device_node *np = dev->of_node; + const struct of_device_id *match; + + /* + * Allow user to use driver_override to bind this driver to a + * transparent bus device which has a different compatible string + * that's not listed in simple_pm_bus_of_match. We don't want to do any + * of the simple-pm-bus tasks for these devices, so return early. + */ + if (pdev->driver_override) + return 0; + + match = of_match_device(dev->driver->of_match_table, dev); + /* + * These are transparent bus devices (not simple-pm-bus matches) that + * have their child nodes populated automatically. So, don't need to + * do anything more. We only match with the device if this driver is + * the most specific match because we don't want to incorrectly bind to + * a device that has a more specific driver. + */ + if (match && match->data) { + if (of_property_match_string(np, "compatible", match->compatible) == 0) + return 0; + else + return -ENODEV; + } dev_dbg(&pdev->dev, "%s\n", __func__); @@ -31,14 +56,25 @@ static int simple_pm_bus_probe(struct pl static int simple_pm_bus_remove(struct platform_device *pdev) { + const void *data = of_device_get_match_data(&pdev->dev); + + if (pdev->driver_override || data) + return 0; + dev_dbg(&pdev->dev, "%s\n", __func__); pm_runtime_disable(&pdev->dev); return 0; } +#define ONLY_BUS ((void *) 1) /* Match if the device is only a bus. */ + static const struct of_device_id simple_pm_bus_of_match[] = { { .compatible = "simple-pm-bus", }, + { .compatible = "simple-bus", .data = ONLY_BUS }, + { .compatible = "simple-mfd", .data = ONLY_BUS }, + { .compatible = "isa", .data = ONLY_BUS }, + { .compatible = "arm,amba-bus", .data = ONLY_BUS }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, simple_pm_bus_of_match);