From patchwork Sat Feb 22 01:40:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 206539 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=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, USER_AGENT_GIT, 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 B736FC35670 for ; Sat, 22 Feb 2020 01:40:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E1ED20722 for ; Sat, 22 Feb 2020 01:40:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vPVdBWrp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727686AbgBVBkw (ORCPT ); Fri, 21 Feb 2020 20:40:52 -0500 Received: from mail-pf1-f202.google.com ([209.85.210.202]:38557 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727934AbgBVBkt (ORCPT ); Fri, 21 Feb 2020 20:40:49 -0500 Received: by mail-pf1-f202.google.com with SMTP id 203so2348664pfx.5 for ; Fri, 21 Feb 2020 17:40:49 -0800 (PST) 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=On3eRiTUnDa5BtXq5RoayDWDf1ZPcj84ltPeiblPUMk=; b=vPVdBWrpXeFBwDzA5UrONBEBUuLscK8+OhywnT5ys4wGN35JJJwulswpUcPpYhqgK1 m50/tOnt9RKLC2CDy1u57pKZq6LvoiBghI1GhMnyrgRkYCQ09XTbH5UbmTXGKlNWbuXQ J3yEVs2TUYmfQDwog+NbQIKm5eJ9aYIVY/QkapqWh4uUSlngOAWp12+cTIlG5o3vOPN2 +awo8m7Idn6jacZxli1lQRoCqwPlXpk4w99usheYI6920vzDSttPbRIKRyN5a+UHZeOi IeuX7ehPEmlkLhMAz2fRsHA3Tok+GPP1xMC6bUPf2tkLmvFdE1m5ArcijHdbPJaf50Lj d1JA== 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=On3eRiTUnDa5BtXq5RoayDWDf1ZPcj84ltPeiblPUMk=; b=Z7blio2+X0QUX04idinr8huPFltRd0C0uqE8uic68WCbrxQFCkXM3ijYIMriGA9kOK apfC2qlMUolgdinUlB4iWqJWuBVKMXTtVthNdLoAZXePD0pudZsOrPNQuYu4/U4+C/qm HpZ66UamJ8uEbjSWE3+1cDIjqbNas5GKXTYL9o4phXrYLuE5gSPPMhvirLnNpppTGvyW J2OKx7rIen7h72ulSd5AWA5KOyz3zuBijh7ng1JQARKeWxvTiwdrZJnRKrOwQBqoWkkO H+2LK3kU7vRWvBJ1xLyjD3QLM4pbY7RzbeAGlWtfUQmCdrkEsv/ns1+zruRxE5yrPXMz 5QdA== X-Gm-Message-State: APjAAAUlHMecw+i0yIzCh8vLwb6Y/e7A8852V5YJCvlrmSW+3iMihha2 +K3F3e1ghDd93vwWKnRbZ9HB63OSfydh+2s= X-Google-Smtp-Source: APXvYqxcK8NEEB7SEtnQp1SzN8VYXqvTOUc2SeP/yCk74iurh+KqopNGx+3yHKNbMZyq5ledAISRoddCngOncis= X-Received: by 2002:a63:4a47:: with SMTP id j7mr40867151pgl.196.1582335649047; Fri, 21 Feb 2020 17:40:49 -0800 (PST) Date: Fri, 21 Feb 2020 17:40:35 -0800 In-Reply-To: <20200222014038.180923-1-saravanak@google.com> Message-Id: <20200222014038.180923-3-saravanak@google.com> Mime-Version: 1.0 References: <20200222014038.180923-1-saravanak@google.com> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [PATCH v1 2/5] driver core: Add fw_devlink kernel commandline option From: Saravana Kannan To: Jonathan Corbet , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ard Biesheuvel , Rob Herring , Frank Rowand , Len Brown Cc: Saravana Kannan , kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org fwnode_operations.add_links allows creating device links from information provided by firmware. fwnode_operations.add_links is currently implemented only by OF/devicetree code and a specific case of efi. However, there's nothing preventing ACPI or other firmware types from implementing it. The OF implementation is currently controlled by a kernel commandline parameter called of_devlink. Since this feature is generic isn't limited to OF, add a generic fw_devlink kernel commandline parameter to control this feature across firmware types. Signed-off-by: Saravana Kannan --- .../admin-guide/kernel-parameters.txt | 18 +++++++++++++ drivers/base/core.c | 27 ++++++++++++++++++- include/linux/fwnode.h | 2 ++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index dbc22d684627..29985152b66d 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1350,6 +1350,24 @@ can be changed at run time by the max_graph_depth file in the tracefs tracing directory. default: 0 (no limit) + fw_devlink= [KNL] Create device links between consumer and supplier + devices by scanning the firmware to infer the + consumer/supplier relationships. This feature is + especially useful when drivers are loaded as modules as + it ensures proper ordering of tasks like device probing + (suppliers first, then consumers), supplier boot state + clean up (only after all consumers have probed), + suspend/resume & runtime PM (consumers first, then + suppliers). + Format: { off | permissive | on | rpm } + off -- Don't create device links from firmware info. + permissive -- Create device links from firmware info + but use it only for ordering boot state clean + up (sync_state() calls). + on -- Create device links from firmware info and use it + to enforce probe and suspend/resume ordering. + rpm -- Like "on", but also use to order runtime PM. + gamecon.map[2|3]= [HW,JOY] Multisystem joystick and NES/SNES/PSX pad support via parallel port (up to 5 devices per port) diff --git a/drivers/base/core.c b/drivers/base/core.c index d32a3aefff32..aeaca8a3aad9 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -2345,6 +2345,31 @@ static int device_private_init(struct device *dev) return 0; } +u32 fw_devlink_flags; +static int __init fw_devlink_setup(char *arg) +{ + if (!arg) + return -EINVAL; + + if (strcmp(arg, "off") == 0) { + fw_devlink_flags = 0; + } else if (strcmp(arg, "permissive") == 0) { + fw_devlink_flags = DL_FLAG_SYNC_STATE_ONLY; + } else if (strcmp(arg, "on") == 0) { + fw_devlink_flags = DL_FLAG_AUTOPROBE_CONSUMER; + } else if (strcmp(arg, "rpm") == 0) { + fw_devlink_flags = DL_FLAG_AUTOPROBE_CONSUMER | + DL_FLAG_PM_RUNTIME; + } + return 0; +} +early_param("fw_devlink", fw_devlink_setup); + +u32 fw_devlink_get_flags(void) +{ + return fw_devlink_flags; +} + /** * device_add - add device to device hierarchy. * @dev: device. @@ -2493,7 +2518,7 @@ int device_add(struct device *dev) */ device_link_add_missing_supplier_links(); - if (fwnode_has_op(dev->fwnode, add_links)) { + if (fw_devlink_flags && fwnode_has_op(dev->fwnode, add_links)) { fw_ret = fwnode_call_int_op(dev->fwnode, add_links, dev); if (fw_ret == -ENODEV) device_link_wait_for_mandatory_supplier(dev); diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 8feeb94b8acc..e0abafbb17f8 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -170,4 +170,6 @@ struct fwnode_operations { } while (false) #define get_dev_from_fwnode(fwnode) get_device((fwnode)->dev) +extern u32 fw_devlink_get_flags(void); + #endif From patchwork Sat Feb 22 01:40:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 206538 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=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, USER_AGENT_GIT, 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 6C1BEC35670 for ; Sat, 22 Feb 2020 01:41:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C1BD20722 for ; Sat, 22 Feb 2020 01:41:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="e/G2izCt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727935AbgBVBk4 (ORCPT ); Fri, 21 Feb 2020 20:40:56 -0500 Received: from mail-pj1-f73.google.com ([209.85.216.73]:54575 "EHLO mail-pj1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727987AbgBVBk4 (ORCPT ); Fri, 21 Feb 2020 20:40:56 -0500 Received: by mail-pj1-f73.google.com with SMTP id a31so1996418pje.4 for ; Fri, 21 Feb 2020 17:40:55 -0800 (PST) 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=dLJUCpK8J7QSv9pjJWTn5rjODL1aEvnJG2mu5Q6XKZg=; b=e/G2izCtRWiEex8vSlfihQZwWbRD38v38ILG4l4r0PBFW4nViuSsYy2XUvAta7Lg+H iwqAKMJhoSdeJvTXWCRNXcpv/oibXCTVqKiCZAtcZ/10EL22JqVpY311ZGjdWeCZ6TWl 8dyvPrRs3TcgxxUs+km0ytcbrL8LP1G4CqJEc+oX/d3UX0nhbrwIbgTzLHjrUY9Qv0iT vMKmD8aus0eCRycaqJkgLLOPimbsn9TPbDIsjZfKcyaWKw7f7WfeukqDuKNG4mncrK8V XMYT45YusmnMzgHTM21b3xNOrzprNYN46RRF/MK+TTqfmcgndJlUtph86LKTOtFenFaQ uNyw== 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=dLJUCpK8J7QSv9pjJWTn5rjODL1aEvnJG2mu5Q6XKZg=; b=snI6JRfyBIjFp2DEQ4bPNc3SlR/o/W5x0hSagY73aCiGyjjuI/uS6Jwm/XU15yPMe5 hBz0wHnzKSfmq91yrb7WNcj9xLw9foibR04qYcrNJYvzEpLMmBiWTOM+CKHiIZwamW4W pSGMtGO12W6x2/1chsshHwaROg9QK96y8hYZMmskXBBGzkIzyb7hPpy114lNy5BawtPH 94ZcjKEaLaFoB5Z1sHEWcJ/zpQlgqkax51pG22dMBffxLJoef4t2VV2Rd78908HXvT6k YNvNn+QbWf72/vDOkWnIBM9J7KAv3WwhQtwX/tL7J89TQ6jK3dFvxsdWypUhCz4/WDG2 9fkA== X-Gm-Message-State: APjAAAWcsz82FQaSp25O6jGa0v8GHmlhYs0ifDuypKM/jBCKx+IpJyTQ ezC1a7LDc99H/Tfyd7apezKDCbNQX7m+zYc= X-Google-Smtp-Source: APXvYqzesfXR7lGxs6e5jxSQUmuI+4SNQj8u282WnFoEoOOntmofH4HAOCXHvIB2dz4XXYHvKMvIdKicGMtW4q8= X-Received: by 2002:a63:be48:: with SMTP id g8mr42416014pgo.23.1582335655195; Fri, 21 Feb 2020 17:40:55 -0800 (PST) Date: Fri, 21 Feb 2020 17:40:37 -0800 In-Reply-To: <20200222014038.180923-1-saravanak@google.com> Message-Id: <20200222014038.180923-5-saravanak@google.com> Mime-Version: 1.0 References: <20200222014038.180923-1-saravanak@google.com> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog Subject: [PATCH v1 4/5] of: property: Start using fw_devlink_get_flags() From: Saravana Kannan To: Jonathan Corbet , Greg Kroah-Hartman , "Rafael J. Wysocki" , Ard Biesheuvel , Rob Herring , Frank Rowand , Len Brown Cc: Saravana Kannan , kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org The fw_devlink_get_flags() provides the right flags to use when creating mandatory device links derived from information provided by the firmware. So, use that. Signed-off-by: Saravana Kannan --- drivers/of/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index e851c57a15b0..15fc9315f1a7 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1262,7 +1262,7 @@ static int of_link_property(struct device *dev, struct device_node *con_np, u32 dl_flags; if (dev->of_node == con_np) - dl_flags = DL_FLAG_AUTOPROBE_CONSUMER; + dl_flags = fw_devlink_get_flags(); else dl_flags = DL_FLAG_SYNC_STATE_ONLY;