Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1119850ybt; Thu, 18 Jun 2020 00:37:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyu/4PscAPvnVzaT1xVxc1LbRoQvoXdKlSSfeQNeANcB72VDGJsTMkPM6UC4CFFkTlYiAbq X-Received: by 2002:a17:906:d923:: with SMTP id rn3mr2776384ejb.261.1592465822235; Thu, 18 Jun 2020 00:37:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592465822; cv=none; d=google.com; s=arc-20160816; b=xRUYmWg9mflWtyHcAcSiBEIticp8k4cXmVTxPm5iPCMKHMlSH9Y61WJvytbByd7PAv yAXCEESc+/c2jk69kcBesLZkWHAj5OEYAfQoEHPWvYE5CkPRQwi1eMO4lbrsjhWPmDAq i8IHLe8y6QszgZ/lgFKMFVcDxzhZexP//J+Y6wFyGHxuZ1gCHO0De3qegCPP2dZBjh4o 9XwW40pPd/R+K2xP68GAlRG+L+Vr3knT0Kdzzmx7LJ2C53tc925OdfbS32oJWN4Y8lsM BIxlnZgNXMFC9b/plC29kQi7VhM08MmWRQwAaGT5N+mRHCwH4e1BMVoUi2meMWwm0rHa 36oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=KEd1sSUwdgNZZk5MhGirM5YmWviEJTOtC4NnWjH7dvs=; b=CFxxWpOlI1qBxXPAbpuqftHN+ml0Jn10/YjYMoz0TMGoZlZbPeGrPrjFLBxnzltFHt 9QV//qGSwtXk/M5qtxU8+9VBafB2TaagFjH5KAFKpl46MC50ucfkJnYkVPNKNReIGfnf 1PDoP3U7oZ2+1kfaFI+fh/6EFKp555pyX+gbeE2sfpEaOYFSj4TsfG+R7M4++y9NMt6N +q9x2MQJYEt9Gt+BaFPfy59tD5XyypF8I7ISKlG7eMvATN57ynaloofMOJFs0lKVktTQ 2AAkTTKQ1nviqocKx3yYY/G/gzXZuuOw8AM1R2RluW4yF+7/GOzm8zOoAdU+oC7Q1dLJ qkNg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i21si1375548ejy.399.2020.06.18.00.36.39; Thu, 18 Jun 2020 00:37:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728145AbgFRHcK (ORCPT + 99 others); Thu, 18 Jun 2020 03:32:10 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:41656 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728096AbgFRHcK (ORCPT ); Thu, 18 Jun 2020 03:32:10 -0400 Received: by mail-ot1-f65.google.com with SMTP id k15so3780769otp.8; Thu, 18 Jun 2020 00:32:07 -0700 (PDT) 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=KEd1sSUwdgNZZk5MhGirM5YmWviEJTOtC4NnWjH7dvs=; b=JgZzxUhwYl2Oo1Y5a2+Y8lVtmKr9ba0dl2S8Zr8HxiIv19FlMPOI/N2pMb/eaC0oSf 4tjY8OFZld1MeXJWrYXQMp4yqSVfzZe+anLZPoZuhuEbcpD+C8mZ5qO81nCXFAWDg0qZ 1s/bQRuMNuJ4Dhp1CqM+P9W1E1b3IvZ07wxESuve4RkOmcqK1OxnffOkQa0gNYKzZVyJ qMDtDgsktFDJeFdYwsod29Eo3gskFSLBOZahCRREVDgaKLCwV5Kb2PdH3wiurEvckN53 w4+FvBhLiwcvAkbKdrkQUpDyjOh25LOe+g1VKMk9S89/v06ORulhpd0/IrAAKJtejhvX +d1w== X-Gm-Message-State: AOAM530dKxiQ2n7T9rraLR9cfskMnXTu0TYjhq65MePO0KXNXFZsiIDK jG4y5Z9RxUBzf0BTLNtbdWpDIpnUZKj9EULsmXU0eU6c X-Received: by 2002:a05:6830:141a:: with SMTP id v26mr2368151otp.250.1592465527028; Thu, 18 Jun 2020 00:32:07 -0700 (PDT) MIME-Version: 1.0 References: <20200515053500.215929-1-saravanak@google.com> <20200515053500.215929-5-saravanak@google.com> In-Reply-To: From: Geert Uytterhoeven Date: Thu, 18 Jun 2020 09:31:55 +0200 Message-ID: Subject: Re: [PATCH v1 4/4] of: platform: Batch fwnode parsing when adding all top level devices To: Saravana Kannan Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Len Brown , Android Kernel Team , Linux Kernel Mailing List , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , ACPI Devel Maling List , Ji Luo , Linux-Renesas , Marek Szyprowski Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Saravana, On Wed, Jun 17, 2020 at 8:36 PM Saravana Kannan wrote: > On Wed, Jun 17, 2020 at 5:20 AM Geert Uytterhoeven wrote: > > On Fri, May 15, 2020 at 7:38 AM Saravana Kannan wrote: > > > The fw_devlink_pause() and fw_devlink_resume() APIs allow batching the > > > parsing of the device tree nodes when a lot of devices are added. This > > > will significantly cut down parsing time (as much a 1 second on some > > > systems). So, use them when adding devices for all the top level device > > > tree nodes in a system. > > > > > > Signed-off-by: Saravana Kannan > > > > This is now commit 93d2e4322aa74c1a ("of: platform: Batch fwnode parsing > > when adding all top level devices") in v5.8-rc1, and I have bisected a > > regression to it: on r8a7740/armadillo and sh73a0/kzm9g, the system can > > no longer be woken up from s2ram by a GPIO key. Reverting the commit > > fixes the issue. > > > > On these systems, the GPIO/PFC block has its interrupt lines connected > > to intermediate interrupt controllers (Renesas INTC), which are in turn > > connected to the main interrupt controller (ARM GIC). The INTC block is > > part of a power and clock domain. Hence if a GPIO is enabled as a > > wake-up source, the INTC is part of the wake-up path, and thus must be > > kept enabled when entering s2ram. > > > > While this commit has no impact on probe order for me (unlike in Marek's > > case), it does have an impact on suspend order: > > - Before this commit: > > 1. The keyboard (gpio-keys) is suspended, and calls > > enable_irq_wake() to inform the upstream interrupt controller > > (INTC) that it is part of the wake-up path, > > 2. INTC is suspended, and calls device_set_wakeup_path() to inform > > the device core that it must be kept enabled, > > 3. The system is woken by pressing a wake-up key. > > > > - After this commit: > > 1. INTC is suspended, and is not aware it is part of the wake-up > > path, so it is disabled by the device core, > > 2. gpio-keys is suspended, and calls enable_irq_wake() in vain, > > 3. Pressing a wake-up key has no effect, as INTC is disabled, and > > the interrupt does not come through. > > > > It looks like no device links are involved, as both gpio-keys and INTC have > > no links. > > Do you have a clue? > > > > Thanks! > > That patch of mine defers probe on all devices added by the > of_platform_default_populate() call, and then once the call returns, > it immediately triggers a deferred probe. > > So all these devices are being probed in parallel in the deferred > probe workqueue while the main "initcall thread" continues down to > further initcalls. It looks like some of the drivers in subsequent > initcalls are assuming that devices in the earlier initcalls always > probe and can't be deferred? > > There are two options. > 1. Fix these drivers. > 2. Add a "flush deferred workqueue" in fw_devlink_resume() > > I'd rather we fix the drivers so that they handle deferred probes > correctly. Thoughts? While the affected drivers should handle deferred probe fine, none of the affected drivers is subject to deferred probing: they all probe successfully on first try (I had added debug prints to platform_drv_probe() to be sure). The affected drivers are still probed in the same order (INTC is one of the earliest drivers probed, gpio-keys is the last). However, during system suspend, gpio-keys is suspended before INTC, which is wrong, as gpio-keys uses an interrupt provided by INTC. Perhaps the "in parallel" is the real culprit, and there is a race condition somewhere? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds